in reply to While behavior
Since the string is exhausted the loop starts from the beginning and the match is never empty.
while normally imposes scalar context but you broke the logic.
just try grabbing more vars to understand what is happening
DB<118> while (my ($line1,$line2) = $data =~ m/^(.*)$/gm) { print "$ +line1 $line2\n"; last if $x++>5 } some random some random some random some random some random some random some random
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: While behavior
by SavannahLion (Pilgrim) on Feb 15, 2014 at 04:45 UTC |