in reply to Re: A useful use of goto
in thread A useful use of goto
Are you sure? IMHO each redo means leaving the scope and "delocalizes" all variables so far.
BTW: no need for a NEXT label, redo alone would do! : )perl -e ' NEXT: { local $a.=$x++; redo NEXT if $x<10; print $a; # prints only 9 } '
UPDATE: I think you're wrong!
only prints "B"! BUT$x=0; { NEXT: { $x==0 ? (local $a="A") : (local $b="B"); redo NEXT if $x++<1; print $a,$b; } }
prints "AB"$x=0; { NEXT: $x==0 ? (local $a="A") : (local $b="B"); goto NEXT if $x++<1; print $a,$b; }
|
|---|