develooper Front page | perl.perl5.porters | Postings from March 2007

Composing @INC from PERL5LIB

Thread Next
From:
andreas.koenig.7os6VVqR
Date:
March 8, 2007 11:43
Subject:
Composing @INC from PERL5LIB
Message ID:
87mz2n7c8h.fsf@k75.linux.bogus
Today on perlmonks:

    http://perlmonks.org/?node_id=603402

Executive summary: "brainsick" expects the translation of PERL5LIB to
@INC at runtime whereas perl seems to compute it once at startup. Or
from a different perspective: the computation is limited by the real
directories existing at startup time.

The following example illustrates this. I run the same program twice
and it fails the first time and succeeds the second time.

In the program I create a module from scratch, create the directories
it resides in and the file itself. I cannot use it because the
directory did not exist at startup time. The second time the directory
is already there and the program succeeds.

Pilot error or perl bug? And -- pardon my ignoracne -- is this
documented?

  % rm -rf /tmp/t2028
  % PERL5LIB=/tmp/t2028 ./installed-perls/perl/p*/perl-5.8.0@30518/bin/perl -e '
  use File::Path qw(mkpath); mkpath "/tmp/t2028/5.9.5";
  open my $fh, ">", "/tmp/t2028/5.9.5/AAAA.pm" or die;
  print $fh "package AAAA; warn q{in AAAA}; 1;\n";
  close $fh;
  require AAAA;'
  Can't locate AAAA.pm in @INC (@INC contains: /tmp/t2028 /home/src/perl/repoperls/installed-perls/perl/pLYsSTG/perl-5.8.0@30518/lib/5.9.5/i686-linux-64int /home/src/perl/repoperls/installed-perls/perl/pLYsSTG/perl-5.8.0@30518/lib/5.9.5 /home/src/perl/repoperls/installed-perls/perl/pLYsSTG/perl-5.8.0@30518/lib/site_perl/5.9.5/i686-linux-64int /home/src/perl/repoperls/installed-perls/perl/pLYsSTG/perl-5.8.0@30518/lib/site_perl/5.9.5 .) at -e line 6.
  zsh: exit 2     PERL5LIB=/tmp/t2028 ./installed-perls/perl/p*/perl-5.8.0@30518/bin/perl -e 
  % PERL5LIB=/tmp/t2028 ./installed-perls/perl/p*/perl-5.8.0@30518/bin/perl -e '
  use File::Path qw(mkpath); mkpath "/tmp/t2028/5.9.5";
  open my $fh, ">", "/tmp/t2028/5.9.5/AAAA.pm" or die;
  print $fh "package AAAA; warn q{in AAAA}; 1;\n";
  close $fh;
  require AAAA;'
  in AAAA at /tmp/t2028/5.9.5/AAAA.pm line 1.


Thanks,
-- 
andreas

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