in reply to Does redo create a new dynamic scope?
<update>
In your example (label added)
LOOP: for( my $i = 1; $i =~ m/\d/, my $j = $i**2; $i++) { print "I saw [$i] and [$j]\n"; redo LOOP if $& == 5; last if $i == 10; }
the redo goes straight to the LOOP label, so the scope of the loop is re-entered, and my-variables get reset (match variables too), as expected. But the execution of the "loop control block" conditional is skipped, which is why $j is undef after the redo.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Does redo create a new dynamic scope? (yes)
by wazoox (Prior) on Jul 19, 2007 at 13:52 UTC | |
by Argel (Prior) on Jul 19, 2007 at 21:19 UTC | |
|
Re^2: Does redo create a new dynamic scope? (yes)
by Argel (Prior) on Jul 19, 2007 at 20:34 UTC |