X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Ftry.pl;fp=samples%2Ftry.pl;h=38b0e50152a312883c9f86f7901347e5d227bbb1;hb=1da764455f3f82a24aad0881beb01f5e4d3cf858;hp=e207e14beef5e9b22bcd8213ed21e0e31fc6a79e;hpb=00eb4513e6dc65546222404eaa0e1c4910587c70;p=perl%2Fmodules%2FScope-Upper.git diff --git a/samples/try.pl b/samples/try.pl index e207e14..38b0e50 100644 --- a/samples/try.pl +++ b/samples/try.pl @@ -25,3 +25,22 @@ 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()" +}