in reply to This code is just freaky...
It's a funky snippet that processes a certain block of lines in the file. Specifically, this code ignores lines between ones that contain "abcd" and ones that contain "def".
The next tells you the code goes back to the block with the label LINE (so nothing in the loop below this line gets executed), and it does so while the following condition is true :
from the point that $line matches "abcd" to the point where it matches "def"
The range operator .. is the key here; notice that it occurs in scalar context, not list context. It's false until the regex on the left matches, where it flips to true, and remains true until the regex on the right matches.
Read it as "everything in between" and you'll have a good idea of what's going on here (that works for how it operates in list context, too)
This behavior is documented in perlop, under the heading "Range operators".
HTH!
perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: This code is just freaky...
by dragonchild (Archbishop) on Jul 27, 2001 at 22:04 UTC | |
by John M. Dlugosz (Monsignor) on Jul 27, 2001 at 22:47 UTC | |
by petral (Curate) on Jul 29, 2001 at 12:41 UTC |