won't go to the while it's next to, but the outer foreach loop. Thus, you don't enter an infinite loop.foreach my $a (1 .. 5) { next while ($a != 2); }
A curious thing was that I wrote the quick program:
How does the range-op-boolean know that $s was a in a previous check. It seems to be maintaining state between invocations.my @strings = ('a', 'b', 'c', 'd', 'e', 'f'); while (my $s = shift @strings) { print "Looking at $s\n"; next while ($s =~ /a/ .. $s =~ /c/); print "$s is OK!\n"; }
Update:
This gives a very interesting output.my @strings = ('a', 'b', 'c', 'd', 'e', 'f'); while (my $s = shift @strings) { print "Looking at $s\n"; my $value = $s =~ /a/ .. $s =~ /c/; print "The value is $value\n"; next if $value; print "$s is OK!\n"; }
I just find that '3E0' thing really odd...Looking at a The value is 1 Looking at b The value is 2 Looking at c The value is 3E0 Looking at d The value is d is OK! Looking at e The value is e is OK! Looking at f The value is f is OK!
In reply to Re: Re: This code is just freaky...
by dragonchild
in thread This code is just freaky...
by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |