X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Ftag.pl;h=0e2e63279d56f1250a68e7976d3cbfc8ef26d9da;hb=3bccb84b883d0410edb8401401e0ac296643caae;hp=9020121a1ce6143eb3b3e6d6b775d1fd14599550;hpb=bac4fc46c2d48ce5db75de6c88e0983aeeedf865;p=perl%2Fmodules%2FScope-Upper.git diff --git a/samples/tag.pl b/samples/tag.pl index 9020121..0e2e632 100644 --- a/samples/tag.pl +++ b/samples/tag.pl @@ -7,7 +7,7 @@ use warnings; use blib; -use Scope::Upper qw/reap localize localize_elem/; +use Scope::Upper qw/reap localize localize_elem localize_delete UP/; sub desc { shift->{desc} } @@ -15,19 +15,21 @@ sub set_tag { my ($desc) = @_; # First localize $x so that it gets destroyed last - localize '$x' => bless({ desc => $desc }, __PACKAGE__) => 1; + localize '$x' => bless({ desc => $desc }, __PACKAGE__) => UP; reap sub { my $pkg = caller; my $x = do { no strict 'refs'; ${$pkg.'::x'} }; # Get the $x in the scope print $x->desc . ": done\n"; - } => 1; + } => UP; localize_elem '%SIG', '__WARN__' => sub { my $pkg = caller; my $x = do { no strict 'refs'; ${$pkg.'::x'} }; # Get the $x in the scope CORE::warn($x->desc . ': ' . join('', @_)); - } => 1; + } => UP; + + localize_delete '@ARGV', $#ARGV => UP; # delete last @ARGV element } package main; @@ -37,6 +39,6 @@ use warnings; { X::set_tag('pie'); - # $x is now a X object - warn 'what'; # warns "pie: what" + # $x is now a X object, and @ARGV has one element less + warn 'what'; # warns "pie: what at ..." } # "pie: done" is printed