Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

@INC Errors

by perl.j (Pilgrim)
on Oct 09, 2011 at 02:43 UTC ( #930403=perlquestion: print w/ replies, xml ) Need Help??
perl.j has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

When I got on my PC today I found an unpleasant surprise. Every day, the first Perl Program I run is a very simple one to make sure everything is working smoothly:

use 5.12.4; use strict; use warnings; my $greeting="Hello, World"; print $greeting;

Today however, things did not go as planned. I got the following error when trying to run the program: Can't locate strict.pm in @INC (@INC contains: .). @INC did not used to contain a ".". What happened here and how can I fix this?

Thanks

--perl.j

Comment on @INC Errors
Select or Download Code
Re: @INC Errors
by chromatic (Archbishop) on Oct 09, 2011 at 02:50 UTC

    @INC normally contains ., unless running in taint mode. @INC should never only contain ., which appears to be your problem. Something changed in your environment.


    Improve your skills with Modern Perl: the free book.

      This problem would be caused by an inability to access Perl's library directories. Maybe you don't have permission anymore, or maybe the directories are gone.

        Does perl remove from @INC at startup (or module load time) if it can't stat those directories? I've never seen that. Clever.


        Improve your skills with Modern Perl: the free book.

      So how do I fix it?
      --perl.j

        Figure out what changed in your environment. Check that the directories in perl -V exist and have permissions which allow you to read them.


        Improve your skills with Modern Perl: the free book.

Re: @INC Errors
by Khen1950fx (Canon) on Oct 09, 2011 at 03:44 UTC
    You can check @INC using a one-liner:
    perl -e 'print join "\n", @INC';
    Or simply run:
    perl -V
    The "." stands for the current directory; hence, it will always come last in the list. Here's a little snippet that I used a couple of years ago. I was experimenting with chromatic's Modern::Perl. It'll enable strict, warnings, and features.
    #!perl use Modern::Perl; use File::PathList; use Data::Dumper::Concise; my $inc = File::PathList->new( paths => \@INC ); say Dumper $inc;
    That was just to satisfy my obsession with Dumper:). You should also check to make sure that perl's in your path.

      You can check @INC using a one-liner:

      The error message already show the contents of @INC

      Or simply run: perl -V

      How do you think perl -V would work if @INC is empty and strict can't be found?

      You should also check to make sure that perl's in your path

      When perl gives you error messages, that means perl is in the path

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://930403]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2014-10-26 05:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (151 votes), past polls