Subject: | Subsequent modification of variable passed to the constructor will change name attribute of existing object. |
If the constructor is passed a package name via a variable and that variable is subsequently changed, the stash's name will change as well.
For example:
my $package = "Test000";
my $pkg1 = Package::Stash->new( $package );
say "PKG1 = ", $pkg1->name;
++ $package;
say "PKG1 = ", $pkg1->name;
results in:
% PACKAGE_STASH_IMPLEMENTATION=XS perl bug.pl
PKG1 = Test000
PKG1 = Test001
This does not occur when using the PP implementation:
% PACKAGE_STASH_IMPLEMENTATION=PP perl bug.pl
PKG1 = Test000
PKG1 = Test000