Sub-refs in @INC screwing with your modules

Adriano Ferreira a.r.ferreira at gmail.com
Wed Aug 5 21:37:47 BST 2009


On Wed, Aug 5, 2009 at 4:48 PM, David Cantrell <david at cantrell.org.uk>wrote:

> As part of an Evil Plan, I am putting a sub-ref into @INC that will
> screw around with modules as they're loaded.  Or at least, I'm trying
> to.  I can't seem to get this to work:
>
> perl -MIO::Scalar -e '
>    unshift @INC, sub {
>        print q{wibble};
>        return IO::Scalar->new(\q{print q{wobble}})
>    };
>    eval "use foo"
> '
>

I don't remember the details if I tried to use IO::Scalar/IO::String to do a
similar thing in Devel::Hide and couldn't (or if I just got lazy), but the
fact is that the current Devel::Hide code uses in-memory handles (which we
got with    open(my $io, '<', \$string)  for Perl 5.8+) and File::Temp for
older perls.

Best,
Adriano


>
> which *should*, if I've RTFM correctly, print "wibblewobble".  But the
> wobble never appears.  What am I doing wrong?
>
> --
> David Cantrell | Hero of the Information Age
>
>  Sobol's Law of Telecom Utilities:
>    Telcos are malicious; cablecos are simply clueless.
>


More information about the london.pm mailing list