Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

why isn't current dir (".") in my @INC ?

by tphyahoo (Vicar)
on Feb 22, 2007 at 13:48 UTC ( #601558=perlquestion: print w/replies, xml ) Need Help??

tphyahoo has asked for the wisdom of the Perl Monks concerning the following question:

I have to be overlooking something obvious here... but what?

The first listing of @INC is missing ".". When I print @INC from perl -e further on, "." is in @INC.

What gives?

(In case it wasn't already clear, the module that isn't being found in @INC is found in the current directory.)

UPDATE: Perhaps I should also mention that I the perl executable was just compiled fresh from source, soI suppose something might have gone awry there...

UPDATE 2: Disregard the last update. Same behavior when run with /usr/bin/perl instead of the freshly compiled perl.

angebote@sql2:~/thartman/idealo-perl/tools/install-idealo-cpan-mods$ p +erl Can't locate in @INC (@INC contains: /home/angebote/thar +tman/shellenv/utils /usr/angebote/perlroot/lib/5.8.6/x86_64-linux /us +r/angebote/perlroot/lib/5.8.6 /usr/angebote/perlroot/lib/site_perl/5. +8.6/x86_64-linux /usr/angebote/perlroot/lib/site_perl/5.8.6 /usr/ange +bote/perlroot/lib/site_perl) at line 6. BEGIN failed--compilation aborted at line 6. angebote@sql2:~/thartman/idealo-perl/tools/install-idealo-cpan-mods$ c +at #!/usr/angebote/perlroot/bin/perl use strict; use warnings; use CPAN; use ModuleList; print "blee\n"; angebote@sql2:~/thartman/idealo-perl/tools/install-idealo-cpan-mods$ / +usr/angebote/perlroot/bin/perl -MModuleList -e 'print "blee\n"' blee angebote@sql2:~/thartman/idealo-perl/tools/install-idealo-cpan-mods$ t +ype perl perl is aliased to `/usr/angebote/perlroot/bin/perl' angebote@sql2:~/thartman/idealo-perl/tools/install-idealo-cpan-mods$ p +erl -MData::Dumper -e 'print Dumper([@INC])' $VAR1 = [ '/home/angebote/thartman/shellenv/utils', '/usr/angebote/perlroot/lib/5.8.6/x86_64-linux', '/usr/angebote/perlroot/lib/5.8.6', '/usr/angebote/perlroot/lib/site_perl/5.8.6/x86_64-linux', '/usr/angebote/perlroot/lib/site_perl/5.8.6', '/usr/angebote/perlroot/lib/site_perl', '.' ]; angebote@sql2:~/thartman/idealo-perl/tools/install-idealo-cpan-mods$

Replies are listed 'Best First'.
Re: why isn't current dir (".") in my @INC ?
by Sidhekin (Priest) on Feb 22, 2007 at 14:12 UTC

    Your use of the CPAN module modifies @INC. (Not that I have any idea why does this, but it does.) To demonstrate:

    sidhekin@blackbox:~$ perl -MData::Dumper -MCPAN -e 'print Dumper \@INC +' $VAR1 = [ '/usr/lib/perl5/5.8.8/i486-linux', '/usr/lib/perl5/5.8.8', '/usr/lib/perl5/site_perl/5.8.8/i486-linux', '/usr/lib/perl5/site_perl/5.8.8', '/usr/lib/perl5/site_perl/5.8.7', '/usr/lib/perl5/site_perl' ]; sidhekin@blackbox:~$ perl -MData::Dumper -e 'print Dumper \@INC' $VAR1 = [ '/usr/lib/perl5/5.8.8/i486-linux', '/usr/lib/perl5/5.8.8', '/usr/lib/perl5/site_perl/5.8.8/i486-linux', '/usr/lib/perl5/site_perl/5.8.8', '/usr/lib/perl5/site_perl/5.8.7', '/usr/lib/perl5/site_perl', '.' ]; sidhekin@blackbox:~$

    Mystery solved? :-)

    print "Just another Perl ${\(trickster and hacker)},"
    The Sidhekin proves Sidhe did it!

      Yes, sidhekin, mystery solved :)

      Well, at least solved enough that I can get the job done.

      If I move the "use" statements back so that CPAN is the last module "used", everything works as I want.

      Why CPAN behaves this way, and whether it should be considered a bug or a feature, is still open I suppose.

        Why CPAN behaves this way, and whether it should be considered a bug or a feature, is still open I suppose.

        Well, CPAN is used to update your system installation, so it seems pretty sensible to me for it to remove '.' from the search path. It doesn't want modules from just somewhere (and "." is somewhere) for modules to satisfy their dependencies, but only from perl's libdirs.


        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
Re: why isn't current dir (".") in my @INC ?
by swampyankee (Parson) on Feb 23, 2007 at 02:25 UTC

    CPAN -- and probably ppm -- don't add . to the @INC list as including the current working directory in a path used by everybody (which is what @INC will generally be) is usually a Bad Idea™. Were @INC include ., it would be possible for a malign person to include a fake module with a name like 'strict' to perform all sorts of unpleasant tasks, up to and including cd /;rm -fr *.


    Insisting on perfect safety is for people who don't have the balls to live in the real world.

    —Mary Shafer, NASA Dryden Flight Research Center

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://601558]
Approved by chargrill
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (None)
    As of 2022-01-26 04:32 GMT
    Find Nodes?
      Voting Booth?
      In 2022, my preferred method to securely store passwords is:

      Results (69 votes). Check out past polls.