Question on perl/cgi paths

Discussion in 'Perl' started by Bill Davis, Jan 4, 2004.

  1. Bill Davis

    Bill Davis Guest

    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
     
    Bill Davis, Jan 4, 2004
    #1
    1. Advertisements

  2. Bill Davis

    Bill Davis Guest


    > 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
     
    Bill Davis, Jan 4, 2004
    #2
    1. Advertisements

  3. Bill Davis

    Karel Guest

    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
     
    Karel, Jan 5, 2004
    #3
  4. Bill Davis

    Bill Davis Guest

    On Mon, 05 Jan 2004 05:37:02 -0800, Karel wrote:

    > 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
     
    Bill Davis, Jan 6, 2004
    #4
  5. Bill Davis

    Jim Gibson Guest

    In article <>, Bill
    Davis <> wrote:

    > On Mon, 05 Jan 2004 05:37:02 -0800, Karel wrote:
    >
    > > 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


    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.
     
    Jim Gibson, Jan 6, 2004
    #5
  6. Bill Davis

    Bill Davis Guest

    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
     
    Bill Davis, Jan 7, 2004
    #6
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jürgen Exner

    Re: CGI Perl "use CGI" statement fail

    Jürgen Exner, Jul 31, 2003, in forum: Perl
    Replies:
    0
    Views:
    1,743
    Jürgen Exner
    Jul 31, 2003
  2. Noah
    Replies:
    5
    Views:
    924
  3. Ohad Lutzky

    Paths, gentleman, paths

    Ohad Lutzky, Nov 6, 2006, in forum: Ruby
    Replies:
    2
    Views:
    278
    David Vallner
    Nov 7, 2006
  4. Sandem

    CGI query - paths and locations

    Sandem, Apr 9, 2004, in forum: Perl Misc
    Replies:
    2
    Views:
    200
    Sandem
    Apr 10, 2004
  5. kath
    Replies:
    4
    Views:
    956
    J. Gleixner
    Apr 9, 2007
Loading...

Share This Page