Subject: | Safe vs Tie::Hash::NamedCapture |
Date: | Fri, 02 Dec 2011 07:22:20 +1100 |
To: | bug-Safe [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
In recent debian i386 perl 5.14.2, if a safe compartment has been
created then a subsequent use of the "%-" named capture gets an error.
For example
use Safe;
Safe->new;
unless (eval '$-{foo}; 1') {
print "error:\n", $@;
}
prints
error:
Can't locate loadable object for module main::Tie::Hash::NamedCapture in @INC
where I hoped that creating (and destroying) a safe would not affect
what is done outside it subsequently.
The "eval" here is just to delay the $-{foo} use until after a safe is
created. It can also be provoked with
use Safe;
BEGIN { Safe->new }
$-{foo}
This seems to be something to do with perl 5.14, as this sort of thing
(much bigger) was working for me in 5.12.
A workaround is to "use Tie::Hash::NamedCapture" before creating a safe
compartment, but dunno if that module is supposed to be for public use.