# new pad here for the file's scope
{
# new pad here for the block's scope
}
sub foo {
# new pad here for the subroutine's scope
}
... etc ...
####
my %foo : Bar = (answer => 42);
##
##
use attributes ();
my %foo;
attributes::->import(__PACKAGE__, \%z, 'Bent');
%foo = (answer => 42);
##
##
use strict;
use warnings;
package AttrTest;
use Data::Dumper;
use PadWalker qw(peek_my);
sub MODIFY_HASH_ATTRIBUTES {
my ($package, $reference, @attributes) = @_;
$package->dump_lex("setting @attributes in $package for $reference");
return;
};
sub dump_lex {
my ($class, $when) = @_;
print "when $when top-level pad is\n";
my $level=0;
while (eval {peek_my(++$level)} && !$@) {};
my $hash = peek_my($level-1);
while (my ($name, $value) = each %$hash) {
my $dumped = Data::Dumper->new([\$value],[$name])->Indent(0)->Dump;
print "\t$value -> $dumped\n";
};
print "\n";
};
INIT { AttrTest->dump_lex('init') };
{
package Foo;
use base qw(AttrTest);
my %foo : Attr = (one => 1);
};
{
package Bar;
use base qw(AttrTest);
use attributes ();
my %bar;
attributes::->import(__PACKAGE__, \%bar, 'Attr');
}
AttrTest->dump_lex('runtime');
##
##
when setting Attr in Foo for HASH(0x8187bec) top-level pad is
SCALAR(0x8186018) -> $%foo = \\'%foo';
when init top-level pad is
HASH(0x818bf68) -> $%bar = \{};
HASH(0x8187bec) -> $%foo = \{};
when setting Attr in Bar for HASH(0x818bf68) top-level pad is
HASH(0x818bf68) -> $%bar = \{};
when runtime top-level pad is
##
##
when init top-level pad is
HASH(0x22dda8) -> $%bar = \{};
HASH(0x3cff4) -> $%foo = \{};
when setting Attr in Foo for HASH(0x3cff4) top-level pad is
when setting Attr in Bar for HASH(0x22dda8) top-level pad is
HASH(0x22dda8) -> $%bar = \{};
when runtime top-level pad is