]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blobdiff - lib/Scope/Upper.pm
Show unwind() and want_at() in the synopsys and the samples
[perl/modules/Scope-Upper.git] / lib / Scope / Upper.pm
index a315552a6479e83c0121400c3a826e7eece1ebb9..ba26e61291537cb5049c51732a7ecc25036f8247 100644 (file)
@@ -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.