10 use Scope::Upper qw<reap localize localize_elem localize_delete :words>;
13 my ($class, $name) = @_;
15 localize '$tag' => bless({ name => $name }, $class) => UP;
17 reap { print Scope->tag->name, ": end\n" } UP;
20 # Get the tag stored in the caller namespace
23 my $pkg = __PACKAGE__;
24 $pkg = caller $l++ while $pkg eq __PACKAGE__;
30 sub name { shift->{name} }
32 # Locally capture warnings and reprint them with the name prefixed
34 localize_elem '%SIG', '__WARN__' => sub {
35 print Scope->tag->name, ': ', @_;
41 for (reverse 0 .. $#INC) {
42 # First UP is the for loop, second is the sub boundary
43 localize_delete '@INC', $_ => UP UP;
50 Scope->new("top"); # initializes $UserLand::tag
54 my $one = 1 + undef; # prints "top: Use of uninitialized value..."
58 eval { delete $INC{"Cwd.pm"}; require Cwd }; # blib loads Cwd
59 print $@; # prints "Can't locate Cwd.pm in @INC (@INC contains:) at..."
62 require Cwd; # loads Cwd.pm
65 } # prints "top: done"