Author: autrijus Date: Fri Apr 21 08:56:22 2006 New Revision: 8899 Modified: doc/trunk/design/syn/S05.pod Log: * S05: Oops, turns out I entirely read perlop.pod incorrectly; "it matches once only" means "it matches successfully once only", not "it performs the match once only". Sorry, TimToady++'s original example of: (state $x) ||= / pattern /; was correct. Modified: doc/trunk/design/syn/S05.pod ============================================================================== --- doc/trunk/design/syn/S05.pod (original) +++ doc/trunk/design/syn/S05.pod Fri Apr 21 08:56:22 2006 @@ -1066,9 +1066,9 @@ The Perl 5 C<?...?> syntax (I<match once>) was rarely used and can be now emulated more cleanly with a state variable: - (state $x) //= / pattern /; # only matches first time + (state $x) ||= / pattern /; # only matches first time -To reset the pattern, simply say C<undefine $x>. +To reset the pattern, simply say C<$x = 0>. =backThread Next