From: brian d foy Date: Wed, 27 Jan 2010 03:54:32 +0000 (-0600) Subject: * Note that the flip-flop operator maintains state across subroutine calls X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8f0f46f8c3254d4701833ef69551f37485a4e9d9;p=p5sagit%2Fp5-mst-13.2.git * Note that the flip-flop operator maintains state across subroutine calls --- diff --git a/pod/perlop.pod b/pod/perlop.pod index d36b090..c062997 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -556,33 +556,33 @@ like this: # code } -The range operator also works on strings, using the magical auto-increment, -see below. +The range operator also works on strings, using the magical +auto-increment, see below. In scalar context, ".." returns a boolean value. The operator is -bistable, like a flip-flop, and emulates the line-range (comma) operator -of B, B, and various editors. Each ".." operator maintains its -own boolean state. It is false as long as its left operand is false. +bistable, like a flip-flop, and emulates the line-range (comma) +operator of B, B, and various editors. Each ".." operator +maintains its own boolean state, even across calls to a subroutine +that contains it. It is false as long as its left operand is false. Once the left operand is true, the range operator stays true until the right operand is true, I which the range operator becomes false -again. It doesn't become false till the next time the range operator is -evaluated. It can test the right operand and become false on the same -evaluation it became true (as in B), but it still returns true once. -If you don't want it to test the right operand until the next -evaluation, as in B, just use three dots ("...") instead of +again. It doesn't become false till the next time the range operator +is evaluated. It can test the right operand and become false on the +same evaluation it became true (as in B), but it still returns +true once. If you don't want it to test the right operand until the +next evaluation, as in B, just use three dots ("...") instead of two. In all other regards, "..." behaves just like ".." does. The right operand is not evaluated while the operator is in the "false" state, and the left operand is not evaluated while the operator is in the "true" state. The precedence is a little lower than || and &&. The value returned is either the empty string for -false, or a sequence number (beginning with 1) for true. The -sequence number is reset for each range encountered. The final -sequence number in a range has the string "E0" appended to it, which -doesn't affect its numeric value, but gives you something to search -for if you want to exclude the endpoint. You can exclude the -beginning point by waiting for the sequence number to be greater -than 1. +false, or a sequence number (beginning with 1) for true. The sequence +number is reset for each range encountered. The final sequence number +in a range has the string "E0" appended to it, which doesn't affect +its numeric value, but gives you something to search for if you want +to exclude the endpoint. You can exclude the beginning point by +waiting for the sequence number to be greater than 1. If either operand of scalar ".." is a constant expression, that operand is considered true if it is equal (C<==>) to the current