Well this is far beyond what the OP wanted!
And your $return->() if $return clause makes it quite esoteric ...
> Try do same with "goto"
... FWIW!
use strict; use warnings; our $target=""; sub rec { my ($i) = @_; $i++; print "i=$i $target\n"; if ($i == 3) { target($i); } if ($i == 5) { goto $target if $target; } if ($i == 7) { return; } rec($i); } sub target { local $target="TARGET"; rec(shift); TARGET: } rec(0); __END__ i=1 i=2 i=3 i=4 TARGET i=5 TARGET i=4 i=5 i=6 i=7
As I said it's only an abstraction of the goto mechanism!
Good night! =)
Cheers Rolf
( addicted to the Perl Programming Language)
In reply to Re^9: Continuations in Perl - Returning to an arbitrary level up the call stack
by LanX
in thread Continuations in Perl - Returning to an arbitrary level up the call stack
by unlinker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |