X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Ftry.pl;h=38b0e50152a312883c9f86f7901347e5d227bbb1;hb=e7846e7f6fded4c4a3139054c5206c1480711867;hp=7e1cb2a7d3019c91881b40ec0add369a4f773512;hpb=6090555243b452a17460ab13510b8a15e0c62f5e;p=perl%2Fmodules%2FScope-Upper.git diff --git a/samples/try.pl b/samples/try.pl index 7e1cb2a..38b0e50 100644 --- a/samples/try.pl +++ b/samples/try.pl @@ -5,7 +5,7 @@ use warnings; use blib; -use Scope::Upper qw/unwind want_at :words/; +use Scope::Upper qw; sub try (&) { my @result = shift->(); @@ -15,13 +15,32 @@ sub try (&) { sub zap { try { - my @things = qw/a b c/; + my @things = qw; return @things; # returns to try() and then outside zap() }; print "NOT REACHED\n"; } -my @stuff = zap(); # @stuff contains qw/a b c/ +my @stuff = zap(); # @stuff contains qw my $stuff = zap(); # $stuff contains 3 print "zap() returns @stuff in list context and $stuff in scalar context\n"; + +{ + package Uplevel; + + use Scope::Upper qw; + + sub target { + faker(@_); + } + + sub faker { + uplevel { + my $sub = (caller 0)[3]; + print "$_[0] from $sub()\n"; + } @_ => CALLER(1); + } + + target('hello'); # "hello from Uplevel::target()" +}