in reply to Re: while(){}continue{}; Useful?
in thread while(){}continue{}; Useful?
Another difficulty with this structure is that lexicals defined within the while block are not available in the continue block:
>perl -wMstrict -le "my $n = 3; while ($n--) { my $i = $n * $n; } continue { print qq{n $n i $i}; } " Global symbol "$i" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors.
I think Perl 6 addresses this through the KEEP block (?) and related mechanisms.
I, too, cannot remember ever using this structure explicitly, but have use it implicitly occasionally via the -p command line switch.
|
|---|