John W. Krahn wrote:
my() happens when the code is compiled so it is *not* re-run every time through the loop. The assignment happens when the code is run so it is re-run every time.

$ perl -e '
for (1..5) {
    my $count;
    $count += 1;
    print $count;
    last if $count == 3;
}
print "\n";
'
11111
$

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to