Can't locate strict.pm in @INC

Posted on 2003-02-27
Medium Priority
Last Modified: 2011-08-18
Hi there, having a problem with perl.

I get this error when trying to run any perl script.

Can't locate strict.pm in @INC (@INC contains: /usr/local/lib/perl5/5.8.0/i686-linux /usr/local/lib/perl5/5.8.0 /usr/local/lib/perl5/site_perl/5.8.0/i686-linux /usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl .) at test line 2.
BEGIN failed--compilation aborted at test line 2.

But I do not get the error when;
I am logged in as Root or,
I remove the line "use strict;"

I am actually running perl 5.6.1, I tried to install 5.8.0 a while back and it totally buggered my system and I had to restore from backup, but somehow it still see's the old perl.

If I do a perl -V I get this back,

So @INC seems to know where to go.

This is very strange, I don't understand where perl is getting this info from, and why it only does it as a normal non SU user.

I removed all files pertaining to 5.8.0, there is nothing in my system for perl 5.8.

This was a Debian package install, I just reinstalled the latest copy and still get the error.

Does anyone know what is happening here?

Thanks for help.


Question by:Airgazm
  • 2
  • 2
  • 2
  • +1

Expert Comment

ID: 8039536
Shot in the dark here.  Try this (as NON-root user):

shell$ for d in /usr/local/lib/perl/5.6.1 \
   /usr/local/share/perl/5.6.1 \
   /usr/lib/perl5 \
   /usr/share/perl5 \
   /usr/lib/perl/5.6.1 \
   /usr/share/perl/5.6.1 \
   /usr/local/lib/site_perl/i386-linux \
   /usr/local/lib/site_perl \
 ; do ls -ld $d >/dev/null && [ -e $d/strict.pm ] && ls -l $d/strict.pm; done

See if you get any "permission denied" errors.  It's conceivable that strict.pm is only readable by root.  I can't think why this would happen, but at least it's a nice easy thing to check.  :)

Expert Comment

ID: 8039870
Check if after installing 5.8 you have the following directories

If they are present then you can have two options:
[1] Change the @INC at compile time using 'lib' module

BEGIN { unshift(@INC, list of new directories to be added) }  

[2] Change the variable "PERL5LIB" to point to the path for 5.8 in your profile file.

Author Comment

ID: 8044178
tomclegg, ahh.

This is what I get back after running that as non root.

-rw-r--r--    1 root     root          377 Nov 30 10:01 /usr/share/perl/5.6.1/strict.pm

I see that strict.pm is owned only by root, should I change this, maybe it needs to be grouped or something.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Accepted Solution

tomclegg earned 400 total points
ID: 8045550
No, it should be owned by root, but readable by everyone.  Which it is.  Hey, I did say it was a shot in the dark.  :)


I just noticed something in your original question (which explains your comment about 5.8.0).

Try this as root.

# which perl; env | grep PERL; perl -V | tail

And again as non-root.

$ which perl; env | grep PERL; perl -V | tail

Perhaps there is more than one perl binary here, and/or root's environment is different than users' environment.

Do all of the following commands give the same results?

# /usr/bin/perl -V

# perl -V

$ /usr/bin/perl -V

$ perl -V


Author Comment

ID: 8045999
tomclegg, I had a friend helping a bit ealier and finally got by the problem. You were on the correct path with your last answer.

Turns out running as non su, Perl was using /usr/local/bin/perl and using su, perl was using /usr/bin/perl

But I checked the dates on /usr/local/bin/perl and found it to be the old 5.8 version, so looks like the debian package install won't write over this, so uninstalling wasn't an option, it would have removed 42 other packages, ouch, so I just recompiled 5.8.0 again, and boom, everything works now.

I am having a couple of module problems now with DBD::mysql but I don't think they are related to this.  

I don't know why the debian package wouldn't just reinstall over this binary, oh well.

Thanks for your help though.

Expert Comment

ID: 21554720
One point of clarification:

In Perl 5.8.5 and earlier "use strict;" was a pragma and strict.pm did not exist.

From Perl 5.8.8 on strict.pm DOES exist and the Perl interpreter will look for it if you "use strict;". But it's still pragma.

So you can hit the same problem when upgrading from versions of Perl 5.8.5 and earlier to versions of Perl 5.8.8 and later. Just make sure you whack any old versions of Perl and get your @INC paths right.

Expert Comment

ID: 21554781
Ah. Sorry -- that's not a clarification at all. :-)

It's not that strict.pm does not exist in earlier versions just that when upgrading, Perl constructs an @INC which includes "site_perl" modules from the earlier version, but does not include standard modules from the earlier version.


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Article by: Tammy
MySQLTuner is a script written in Perl that allows you to review a MySQL installation quickly and make adjustments to increase performance and stability. The current configuration variables and status data is retrieved and presented in a brief forma…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question