On 08/09/2013 04:34 AM, Jing Yu wrote:
You probably can use 'state' instead of 'my' to keep $counter in scope.foreach my $e ( 'a'..'z' ) { state $counter++; if ( $counter == 5 ) { say $e; } }
and what if that code is run again in the same program? it will keep the last count and keep going causing it to loop way beyond 5.
uri -- Uri Guttman - The Perl Hunter The Best Perl Jobs, The Best Perl Hackers http://PerlHunter.com -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
