Perl can't locate a .pm in @INC

G

Gary Hartl

Hello all again,

I'm not much of a perl programer but I am trying to get this script to
run and it is giving me a headache :)

I'm getting premature end of script header errors and I'm pretty sure
why.

Here is everything I think is important for this situation, if i'm
missing something please let me know and I'll supply anything else.

I have some .pm files ina directory called /home/mach10/dist/lib

the first line of the script calls
use lib ($ENV{'MACH10_LIB'} || '/home/mach10/dist/lib');

then it calls the offending module:
use Skyweb;

seems like that should work for me ( with my limited knowledge )
now if i try to run the script from browswer i get the follow error in
my apache logs:

Can't locate Skyweb.pm in @INC (@INC contains: /home/mach10/dist/lib
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at
/usr/local/apache/cgi-bin/sp/mach10.pl line 4.
BEGIN failed--compilation aborted at
/usr/local/apache/cgi-bin/sp/mach10.pl line 4.
[Tue Nov 4 16:23:16 2003] [error] [client 192.168.1.101] Premature
end of script headers: /usr/local/apache/cgi-bin/sp/mach10.pl


I'm so novice to perl that i'm completely lost....anyone have any
ideas.

Thanks for all the help in advance.

Gary
 
J

James E Keenan

Gary Hartl said:
Hello all again,

I'm not much of a perl programer but I am trying to get this script to
run and it is giving me a headache :)

I'm getting premature end of script header errors and I'm pretty sure
why.

Here is everything I think is important for this situation, if i'm
missing something please let me know and I'll supply anything else.

I have some .pm files ina directory called /home/mach10/dist/lib

the first line of the script calls
use lib ($ENV{'MACH10_LIB'} || '/home/mach10/dist/lib');
The 'use lib' command is expecting a *list* of directories in which to
search for Perl modules. Items in the list are, in almost all cases,
separated by commas. You are separating the items in your list by Perl's ||
operator. This would be correct if this were the body of, say, an 'if'
condition, but it's not a Perl list. Try:
use lib ($ENV{'MACH10_LIB'} , '/home/mach10/dist/lib');
and let us know the results.

jimk
 
T

Tad McClellan

Gary Hartl said:
I'm getting premature end of script header errors and I'm pretty sure ^^^^^^^^^^^
why.
^^^


But you are not going to tell us?

Is this a test? :)

use lib ($ENV{'MACH10_LIB'} || '/home/mach10/dist/lib');
use Skyweb;
Can't locate Skyweb.pm in @INC (@INC contains: /home/mach10/dist/lib


An essential missing bit of information is where _is_ Skyweb.pm installed?

If it is at

/home/mach10/dist/lib/Skyweb.pm

then I don't know what the problem might be...
 
G

Gunnar Hjalmarsson

James said:
The 'use lib' command is expecting a *list* of directories in which
to search for Perl modules. Items in the list are, in almost all
cases, separated by commas. You are separating the items in your
list by Perl's || operator. This would be correct if this were the
body of, say, an 'if' condition, but it's not a Perl list. Try:
use lib ($ENV{'MACH10_LIB'} , '/home/mach10/dist/lib');
and let us know the results.

I don't understand that, Jim. Thought that the expression within
parentheses returned a 'LIST', even if it happens to consist of only
one element: It returns either the value of $ENV{'MACH10_LIB'}, or, if
that value is not true, the string '/home/mach10/dist/lib'.

Doesn't that tell us that OP's "use lib" statement worked?

Nevertheless, I'm not able to suggest a solution.
 
J

James Willmore

Hello all again,

I'm not much of a perl programer but I am trying to get this script to
run and it is giving me a headache :)

I'm getting premature end of script header errors and I'm pretty sure
why.

Here is everything I think is important for this situation, if i'm
missing something please let me know and I'll supply anything else.

I have some .pm files ina directory called /home/mach10/dist/lib

the first line of the script calls
use lib ($ENV{'MACH10_LIB'} || '/home/mach10/dist/lib');
<snip>

You could just set the $ENV{'MACH10_LIB'} variable _first_, then set
the 'lib' path accordingly.

--untested--
$ENV{'MACH10_LIB'} = '/home/mach10/dist/lib' unless defined
$ENV{'MACH10_LIB'};
use lib "$ENV{'MACH10_LIB'}";
--untested--

HTH

Jim
(jwillmore _at_ adelphia _dot_ net)
 
D

Darin McBride

Gary said:
Hello all again,

I'm not much of a perl programer but I am trying to get this script to
run and it is giving me a headache :)

I'm getting premature end of script header errors and I'm pretty sure
why.

Here is everything I think is important for this situation, if i'm
missing something please let me know and I'll supply anything else.

I have some .pm files ina directory called /home/mach10/dist/lib

the first line of the script calls
use lib ($ENV{'MACH10_LIB'} || '/home/mach10/dist/lib');

then it calls the offending module:
use Skyweb;

seems like that should work for me ( with my limited knowledge )
now if i try to run the script from browswer i get the follow error in
my apache logs:

How about running it manually? If that doesn't work, then you don't
have Skyweb.pm where you claim to above ;-)

If it does, and under the assumption that you're not lying/deceived
about the above I would have to assume it will work, you've just hit
one of my personal most-frequently-hit problem that bites me nearly
every time I start a new web app. Permissions.

Generally, the web server runs as "apache" or some other user. Not as
you. And that user probably doesn't have read/execute permissions in
one or more of /home, /home/mach10, /home/mach10/dist, or
/home/mach10/dist/lib. Or it may not have read permissions to the
module in question, but in that case I believe you'd get a different
error message than this, so I would bet on the directories.
Can't locate Skyweb.pm in @INC (@INC contains: /home/mach10/dist/lib
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at
/usr/local/apache/cgi-bin/sp/mach10.pl line 4.
BEGIN failed--compilation aborted at
/usr/local/apache/cgi-bin/sp/mach10.pl line 4.
[Tue Nov 4 16:23:16 2003] [error] [client 192.168.1.101] Premature
end of script headers: /usr/local/apache/cgi-bin/sp/mach10.pl


I'm so novice to perl that i'm completely lost....anyone have any
ideas.

I do not think this is a perl issue per se, but a unix one.
 
J

James Willmore

Doesn't that tell us that OP's "use lib" statement worked?

You're right. I posted something similar as a solution, but you're
right.
Nevertheless, I'm not able to suggest a solution.

Nor can I :-(

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Pascal Users: To show respect for the 313th anniversary
<(tomorrow) of the death of Blaise Pascal, your programs will be
run at half speed.
 
G

Gary Hartl

Well i got lazy, and fixed the problem the good old fashion way.

I just copied the .pm's to my /usr/lib/perl5/5.8.0 directory and it
works, outside of my previous post with <INFILE> errors ( which i have
no clue about), but that is left for another post :)

Cheers and Thanks to all for the replies, they were most helpful :)

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top