Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Scalar range operator again

by dsheroh (Prior)
on Jul 06, 2012 at 12:13 UTC ( #980248=note: print w/replies, xml ) Need Help??

in reply to Scalar range operator again

I am assuming here that Perl processes each array element char by char "from left to right"
You assume incorrectly. The array is processed element-by-element, not character-by-character. The first element of the array is ca and the second element is qw.

On the first pass through the loop, the flip-flop's state is false, so ca is tested against /a/, which matches, so it returns true, but it also tests against /c/ which resets it to false. From perldoc perlop:

Once the left operand is true, the range operator stays true until the right operand is true, AFTER 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 awk), but it still returns true once. If you don't want it to test the right operand until the next evaluation, as in sed, just use three dots ("...") instead of two. In all other regards, "..." behaves just like ".." does.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://980248]
[Corion]: Heh - I just realized, $work management just declared "no raises for anybody this year", and I'm not even angry about that. Even though that implicitly means "raises for the people with an automatic 5% raise in their contract", which the newly-merged ...
[Corion]: ... coworkers have. But I guess I've gone more mellow since I get to relax more, and such stuff doesn't make me as angry as it used to.
[Corion]: $boss will still get to listen to my interpretation :-D
[Eily]: hey, I'm just behind Larry in SioB \o/

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2018-01-22 11:02 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (233 votes). Check out past polls.