develooper Front page | perl.perl5.porters | Postings from January 2004

Re: Recursive call to Perl_load_module in PerlIO_find_layer

Thread Previous | Thread Next
From:
Elizabeth Mattijsen
Date:
January 26, 2004 00:46
Subject:
Re: Recursive call to Perl_load_module in PerlIO_find_layer
Message ID:
p05111b03bc3a83328a02@[192.168.56.3]
At 21:33 +0100 1/25/04, Rafael Garcia-Suarez wrote:
>Elizabeth Mattijsen wrote:
>  > dies with the error:
>  >   Recursive call to Perl_load_module in PerlIO_find_layer line 3.
>>    BEGIN failed--compilation aborted line 6.
>  >   BEGIN failed--compilation aborted line 6.
>Because it tries to load PerlIO::Scalar while trying to load
>PerlIO::Scalar.

Indeed.  This works like a charm:

BEGIN {
     require PerlIO::Scalar;
     unshift( @INC,sub {
         my $data; open( my $in,'<',\$data );
     } );
}
use Foo;

But I would never have gotten from the error message to this fix.

But this implies that PerlIO::Scalar is only loaded the first time 
you try to do an open() like that.  Are there many more situations 
like that in Perl nowadays?  Is there a list of this modules that get 
automatically loaded on demand?  Could be important for optimizing 
Perl on mod_perl prefork MPMs...


>  > I ran into this while developing my new "ifdef" pragma (soon to be
>>  found on CPAN, now also available from http://www.liz.nl/CPAN ).
>>
>>  I actually don't need the functionality to create a handle on a
>>  scalar while in an @INC handler anymore, as I've chosen a line based
>>  approach.  But it still makes me wonder why this is would be a
>  > problem.  And if and how it can be circumvented.
>You can shift() instead of unshift(), or load PerlIO::Scalar explicitly.

Why would removing stuff with shift() work.  Do you mean push()?  But 
that would defeat my purpose, as it then would only get called for 
modules that couldn't get loaded.


Liz

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About