Lori713 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I've got a large file I'm considering upgrading from 5.005 to 5.6.1, and was curious about what kind of "errors" I might see. So, I changed my shebang link from "perl5" to "perl5_6_1" (which is how our directories on the Unix box are labeled - see below). I telnet'd to the Unix box to do a syntax check and I got the following error message:

/local/www/scripts/>perl -c nc_pf_56mainmenu.pl
Content-type: text/html
Software error:
Wed Sep 10 09:57:00 2003 CTlib.pm: Can't locate Sybase/CTlib.pm in @INC
(@INC contains: /usr/perl5/5.00503/sun4-solaris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/sun4-solaris /usr/perl5/site_perl/5.005 .)
at nc_pf_56mainmenu.pl line 12.
BEGIN failed--compilation aborted at nc_pf_56mainmenu.pl line 12.

I confirmed that the Sybase::CTLIB is in the following paths:

usr/local/lib/perl5/site_perl/Sybase/CTlib.pm
usr/local/lib/perl_5_6_1/site_perl/Sybase/CTlib.pm

I understand that the @INC is where the program will go look for stuff (and I think I already know how to push a directory onto @INC because I've had to look it up in here before), but my question is...
Why is it pointing to those old directories when I tell it the perl_5_6_1 directory in the shebang line?

My current (erroring) shebang line is: #!/usr/local/bin/perl5_6_1
The following works for the 5.0 version: #!/usr/local/bin/perl5

BTW, I also tried a "perl -d myfilename.pl" and plain old "perl myfilename.pl" just to see what would happen... I get the same error messages.

Thanks for any insights you can provide.

Lori

Replies are listed 'Best First'.
Re: Error on converting 5.0 script to 5.6 script
by edan (Curate) on Sep 10, 2003 at 14:41 UTC

    When you invoke your script like you are doing:

    perl -c nc_pf_56mainmenu.pl

    ... you are not running the perl interpreter that is on your shebang line: you are explicitly running the first perl that is found in your PATH. Try one of the following:

    • /usr/local/bin/perl5_6_1 -c nc_pf_56mainmenu.pl
    • Run the script: nc_pf_56mainmenu.pl
    • If you don't want to run it, just compile, then add -c to the shebang line, then execute the script directly: nc_pf_56mainmenu.pl

    --
    3dan

      Another, slightly less secure, option is to do /usr/bin/env perl5_6_1 and that will execute the first perl5_6_1 in your $PATH. The reason it's less secure is that it depends on your path, which could be hijacked. It's always best, in production code, to be as explicit as possible.

      ------
      We are the carpenters and bricklayers of the Information Age.

      The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

      Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Re: Error on converting 5.0 script to 5.6 script
by Zaxo (Archbishop) on Sep 10, 2003 at 14:35 UTC

    Do you have the PERL5LIB environment variable set to the old list? That could cause your errors. If that fails, check perl5_6_1 -V to get the whole environment.

    After Compline,
    Zaxo

Re: Error on converting 5.0 script to 5.6 script
by Lori713 (Pilgrim) on Sep 10, 2003 at 15:11 UTC
    <sigh> No wonder my original searches through google and this site didn't pull up what I was looking for.</sigh>

    I needed to look for PERL5LIB (which, being a newbie, never occurred to me...) ;-)

    Great advice... I've already founds tons of info searching on "PERL5LIB." I'll go poking around and try your suggestions!

    Many thanks!