dio wasn't refering to enclosing scopes. Compare
sub test { my ($x) = shift; return if !$x; our @o = $x; test($x-1); print("@o\n"); } test(3); # 1,1,1
with
sub test { my ($x) = shift; return if !$x; local our @o = $x; test($x-1); print("@o\n"); } test(3); # 1,2,3
The same problem occurs without recursion too. Compare
sub foo { my ($x) = shift; our @o = 1; bar(); print("@o\n"); } sub bar { my ($x) = shift; our @o = 2; print("@o\n"); } foo(); # 2,2
with
sub foo { my ($x) = shift; local our @o = 1; bar(); print("@o\n"); } sub bar { my ($x) = shift; local our @o = 2; print("@o\n"); } foo(); # 2,1
In reply to Re^7: Multiple uses of (?{ code }) do not appear to be called
by ikegami
in thread Multiple uses of (?{ code }) do not appear to be called
by bsdz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |