On Wed Dec 21 05:16:28 2011, RIBASUSHI wrote:
Show quoted text> On Tue Dec 20 20:59:15 2011, SPROUT wrote:
> > namespace::clean tickles a bug in perl 5.10-5.15.6, which crashes when
> > cloning a tied hint
> > hash:
> >
> > use Devel::Hide 'B::Hooks::EndOfScope';
> > use sort "stable";
> > use namespace::clean;
> > use sort "stable";
> > {;}
> >
> > I haven’t written tests to prove it, but I believe there are other
> > problems with it, too: It does
> > not save the existing values in %^H before tying, so whatever keys are
> > there will appear to
> > vanish from the point of view of other BEGIN blocks in the same scope.
>
> This looks like the actual problem - I simply forgot to do the proper
> cloning myself. Doing so passes on all 5.10+ perls. The cloner of
> 5.8.any still dies a fiery death, I am trying to figure out a trick for
> this.
>
> In any case - I think the result is rather satisfactory on 5.10+, and
> far from "is broken/can't be made to work". What do you guys think? :)
It’s a lot better, but there’s still a snag. Due to another perl bug, still present in blead, the
hints become invisible to inner scopes at compile time, but not run time. BTW, I was wrong
about ties preventing the hint magic from coming into play. Devel::Peek shows that the
magically generated elements have both tie *and* hint magic.
use Data::Dumper;
sub dump_runtime_hints {
print Dumper +(caller 0)[10]; warn ' '
}
BEGIN {
$ENV{NAMESPACE_CLEAN_USE_PP} = 1;
%^H = 'a'..'h';
}
use namespace::clean;
BEGIN {
print Dumper \%^H;
warn ' ';
}
dump_runtime_hints;
{
BEGIN {
print Dumper \%^H;
warn ' ';
}
dump_runtime_hints;
}
__END__
$VAR1 = {
'e' => 'f',
'c' => 'd',
'a' => 'b',
'g' => 'h'
};
at - line 14.
$VAR1 = {};
at - line 20.
$VAR1 = {
'e' => 'f',
'c' => 'd',
'a' => 'b',
'g' => 'h'
};
at - line 4.
$VAR1 = {
'e' => 'f',
'c' => 'd',
'a' => 'b',
'g' => 'h'
};
at - line 4.