Question on perl/cgi paths

B

Bill Davis

I am just starting to play with CGI programs on a box with RH 9. Testing
to see if I had the stuff installed I used a very simple script like so...

#!/usr/bin/perl -w
use strict;
use CGI;

It told me that it couldn't find CGI.pm and sure enough, that apparently
doesn't come on the RedHat 9 distro. So I installed the latest version of
Perl (5.8.1, I think) and CGI.pm came with it.

But when I run the above test, I get the following...

Can't locate CGI.pm in @INC (@INC contains:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0...
etc...etc

Perl -v gives the correct new version of 5.8.1, but the above seems to say
that I have a path variable somewhere that is pointing to the old version.
It is the @INC that I am hung up on. None of my books have a reference
to it and naturally the Perl website search function is down at the moment.
Neither do the man pages, or else I am not giving the right search args.

Anybody give me some insite on what the @INC is?

Thanks
Bill Davis
 
B

Bill Davis

Can't locate CGI.pm in @INC (@INC contains:
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0...
etc...etc

OK, lots of searching gets the answer that @INC is the variable that
contains the list of paths to search. No problem, since that is what I
thought it would be. And I finally found it in a book, also.

However, all of the advice on googling and the book says the same thing -
just change the variable to match your paths to your modules. Great. They
just left out one thing - where is the file (or variable) that is to be
changed?

The usual answer is to just recompile and install CGI.pm and that will set
the paths to the proper location. However, my usage of Linux is a
learning progress at the moment rather than a production usage, and I
would like to know the details of why rather than just fix it and go.

Bill Davis
 
K

Karel

Bill

Your script calls /usr/bin/perl for interpreting the script at line 1.
But is this the location of the new perl 5.8.1 version you installed?

To check where perl is located type the command :
which perl
in a Xterm. If this differs from the /usr/bin location use this
location in the fist line of your scripts.

Other wise change @INC as follows:
no lib qw:)All .); # will clear @INC
use lib qw( your path's space separated) ; # will set @INC to your
path's

Cheers

KArel
 
B

Bill Davis

Bill

Your script calls /usr/bin/perl for interpreting the script at line 1.
But is this the location of the new perl 5.8.1 version you installed?

To check where perl is located type the command :
which perl
in a Xterm. If this differs from the /usr/bin location use this
location in the fist line of your scripts.

Other wise change @INC as follows:
no lib qw:)All .); # will clear @INC
use lib qw( your path's space separated) ; # will set @INC to your
path's

Thanks. I got the problem fixed, but like I said, I am trying to
understand the process. I am still unsure where @INC resides, although I
can now change it all day long. I am afraid that I am an unreconstructed
empiricist - I like to be able to SEE the code that I am working on:)

Thanks
BD
 
J

Jim Gibson

Bill said:
Thanks. I got the problem fixed, but like I said, I am trying to
understand the process. I am still unsure where @INC resides, although I
can now change it all day long. I am afraid that I am an unreconstructed
empiricist - I like to be able to SEE the code that I am working on:)

Thanks
BD

The @INC variable is set by the perl interpreter before your program
executes. Use "perl -V" (capital V) to see what it normally is. Try

perldoc -q 'How do I add a directory to my include path'

for ways to add libraries to @INC. However, you don't want to be
maintaining your own special @INC array value. Make sure you always use
the same perl program for installing modules that you use for running
programs, and the installer should put the modules in one of the
directories already in your @INC.

FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future
for better response.
 
B

Bill Davis

O
FYI: this newsgroup is defunct. Try comp.lang.perl.misc in the future
for better response.


Thanks. I was wondering where everybody was. On a dialup that is maxed
out by the phone company at 26k, it is hard to sample enough groups to
find out where everyone is hanging out.

BD
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top