Sub-refs in @INC screwing with your modules

David Cantrell david at cantrell.org.uk
Thu Aug 6 14:31:34 BST 2009


On Thu, Aug 06, 2009 at 09:44:24AM +0100, Aaron Crane wrote:
> Apparently open-from-a-string internally loads a module to do its magic:
>   $ perl -le 'print scalar keys %INC; open my $fh, "<", \""; print for
> keys %INC'
>   0
>   XSLoader.pm
>   PerlIO/scalar.pm
>   PerlIO.pm
> So you can make this work by doing open-from-a-string at least once
> before the @INC hook gets called:

In my case that's not necessary, because my Voodoo will return undef
for attempts to load any module it's not been told about.  Anyone trying
to use my crazy code on XSLoader or PerlIO::* deserves what they get!

http://www.cantrell.org.uk/cgit/cgit.cgi/perlmodules/tree/Sub-WrapPackages/lib/Sub/WrapPackages.pm

Incidentally, if anyone can think of a way of doing the Stuff in lines
160-171 without using a global variable, do please let me know.  The two
approaches I tried and which didn't work were:

* local $Sub::WrapPackages::params - doesn't work because it
  de-localises at the end of this subroutine, so is gone by the time it
  is needed;
* use Data::Dumper to stringify the %params, but that doesn't handle
  subrefs

-- 
David Cantrell | even more awesome than a panda-fur coat

Just because it is possible to do this sort of thing
in the English language doesn't mean it should be done


More information about the london.pm mailing list