c:\@Work\Perl\monks>perl -wMstrict -le "my $done = 'got stuff to do'; print qq{'$done'}; ;; for my $i (1 .. 4) { print $i; if ($i == 2) { $done = 'finished'; last; } } print qq{'$done'}; " 'got stuff to do' 1 2 'finished'
Note that you need to execute last after setting ('exporting') the $done flag, not before as in your most recently posted originally posted code.
In reply to Re: scalar out of a loop
by AnomalousMonk
in thread scalar out of a loop
by mitchreward
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |