X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Ftag.pl;fp=samples%2Ftag.pl;h=e28aae00488b239c633161caba55de0b90db19c4;hb=9a258ccdcca73cc6ca9470c06e7db103c3ba8193;hp=0e2e63279d56f1250a68e7976d3cbfc8ef26d9da;hpb=b74d16df98351c4bacb0a1a9d029ce7d7924591f;p=perl%2Fmodules%2FScope-Upper.git diff --git a/samples/tag.pl b/samples/tag.pl index 0e2e632..e28aae0 100644 --- a/samples/tag.pl +++ b/samples/tag.pl @@ -7,7 +7,9 @@ use warnings; use blib; -use Scope::Upper qw/reap localize localize_elem localize_delete UP/; +use Scope::Upper qw/reap localize localize_elem localize_delete :words/; + +die 'run this script with some arguments!' unless @ARGV; sub desc { shift->{desc} } @@ -21,15 +23,16 @@ sub set_tag { my $pkg = caller; my $x = do { no strict 'refs'; ${$pkg.'::x'} }; # Get the $x in the scope print $x->desc . ": done\n"; - } => UP; + } => SCOPE 1; # same as UP here 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('', @_)); - } => UP; + } => UP CALLER 0; # same as UP here - localize_delete '@ARGV', $#ARGV => UP; # delete last @ARGV element + # delete last @ARGV element + localize_delete '@ARGV', -1 => UP SUB HERE; # same as UP here } package main; @@ -41,4 +44,5 @@ use warnings; X::set_tag('pie'); # $x is now a X object, and @ARGV has one element less warn 'what'; # warns "pie: what at ..." + warn "\@ARGV contains [@ARGV]"; } # "pie: done" is printed