The constant form of the flip-flop only operates against $.. Ie. The line number of the current file being read. Hence the first loop below produces the output expected, but the second does not.
#! perl -slw use strict; while( <DATA> ) { print if 1..4; } for ( 1 .. 8 ) { print if 1..4; } __DATA__ line 1 line 2 line 3 line 4 line 5 line 6 line 7 line 8
In reply to Re^2: modifying a string in place
by BrowserUk
in thread modifying a string in place
by davidj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |