X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FScope%2FUpper.pm;h=ba26e61291537cb5049c51732a7ecc25036f8247;hb=086bb57f3e5a02fc333105c08b3ce99318f94fe6;hp=a315552a6479e83c0121400c3a826e7eece1ebb9;hpb=700ce600c7f40f6889a4b11f21fe45eff6040335;p=perl%2Fmodules%2FScope-Upper.git diff --git a/lib/Scope/Upper.pm b/lib/Scope/Upper.pm index a315552..ba26e61 100644 --- a/lib/Scope/Upper.pm +++ b/lib/Scope/Upper.pm @@ -56,6 +56,26 @@ BEGIN { ... } # "pie: done" is printed + package Z; + + use Scope::Upper qw/unwind want_at :words/; + + sub try (&) { + my @result = shift->(); + my $cx = SUB UP SUB; + unwind +(want_at($cx) ? @result : scalar @result) => $cx; + } + + ... + + sub zap { + try { + return @things; # returns to try() and then outside zap() + } + } + + my @what = zap(); # @what contains @things + =head1 DESCRIPTION This module lets you defer actions that will take place when the control flow returns into an upper scope.