in reply to Re^2: cross scope gotos?
in thread cross scope gotos?
Maybe this code makes it clearer:
sub jump { print "in\n"; goto BACK }; sub jump2 {goto &jump } sub cont { for $i (0..1) { for $j ("a".."b") { print "$i,$j\t"; jump2(); # works #goto &jump; # fails BACK: } } } cont();
OUTPUT
in simple words:0,a in 0,b in 1,a in 1,b in
It's not only possible to jump within the same scope, but also into the scope of previous ("outer") call frames.
(Pity I thought I found an easy pattern for continuations...)
Cheers Rolf
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: cross scope gotos?
by Anonymous Monk on Apr 06, 2010 at 13:20 UTC | |
by LanX (Saint) on Apr 06, 2010 at 13:28 UTC |
In Section
Seekers of Perl Wisdom