Sub-refs in @INC screwing with your modules
Randy J. Ray
rjray at blackperl.com
Wed Aug 5 20:57:21 BST 2009
David Cantrell 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"
> '
>
> which *should*, if I've RTFM correctly, print "wibblewobble". But the
> wobble never appears. What am I doing wrong?
Does the IO::Scalar object appear as a proper typeglob to Perl? According to
"perldoc -f require", if the return value looks like a tied filehandle it gets
discarded:
"Note that this file handle must be
a real file handle (strictly a typeglob, or reference to a
typeglob, blessed or unblessed) - tied file handles will be
ignored and return value processing will stop there."
Randy
--
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Randy J. Ray Sunnyvale, CA http://www.rjray.org rjray at blackperl.com
Silicon Valley Scale Modelers: http://www.svsm.org
More information about the london.pm
mailing list