8 use Scope::Upper qw/reap localize localize_elem localize_delete :words/;
11 my ($class, $name) = @_;
13 localize '$tag' => bless({ name => $name }, $class) => UP;
15 reap { print Scope->tag->name, ": end\n" } UP;
18 # Get the tag stored in the caller namespace
21 my $pkg = __PACKAGE__;
22 $pkg = caller $l++ while $pkg eq __PACKAGE__;
28 sub name { shift->{name} }
30 # Locally capture warnings and reprint them with the name prefixed
32 localize_elem '%SIG', '__WARN__' => sub {
33 print Scope->tag->name, ': ', @_;
39 for (reverse 0 .. $#INC) {
40 # First UP is the for loop, second is the sub boundary
41 localize_delete '@INC', $_ => UP UP;
48 Scope->new("top"); # initializes $UserLand::tag
52 my $one = 1 + undef; # prints "top: Use of uninitialized value..."
57 print $@; # prints "Can't locate Cwd.pm in @INC (@INC contains:) at..."
60 require Cwd; # loads Cwd.pm
63 } # prints "top: done"