Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

perl cant find it anymore!

by Octavian (Monk)
on Jun 18, 2001 at 18:44 UTC ( [id://89313]=perlquestion: print w/replies, xml ) Need Help??

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

ok, I installed HP 11.11 or 11.i onto one of our boxes, and loaded all our scripts back onto the box...the default version of perl with the load was 5.00502...and one of my scripts that had require timelocal.pl in it started freakin out...saying it wasnt found with the typical Can't locate timelocal.pl in @INC error message.....so to try and quickly fix it, I installed 5.6.1 using the depot I got from software porting and depot centre for HP-UX....which worked on all my other boxes....anyways, that didnt fix it...then I noticed it is looking in the wrong directory:
@INC contains: /opt/perl5/lib/5.00502/PA-RISC1.1 /opt/perl5/lib/5.00502 /opt/perl5/lib/site_perl/5.005/PA-RISC1.1 /opt/perl5/lib/site_perl/5.005 .)
the timelocal.pl script is located in the /opt/perl5/lib/5.6.1 directory...and if I am Cd'd into that directory, the program works!?!? is there a config file somewhere for perl that tells it where to look? kinda like setting the PATH?

Replies are listed 'Best First'.
Re: perl cant find it anymore!
by azatoth (Curate) on Jun 18, 2001 at 19:06 UTC
      You need to change @INC in a BEGIN block in order for it to affect use commands, since they take effect at BEGIN-time. But Octavian is using require 'timelocal.pl';, which takes place at run time (Octavian: you seem to be using some old code with some old syntax; are you sure there isn't something newer that might be easier to use?). So Beatnik's change of @INC at run time is enough, as long as it takes place before the require.

      Yet More Ways of setting @INC before your script starts running (and thus in time to affect both use and require):

      1. Add them to your shebang line:
        #!/path/to/perl -w -I/opt/perl5/lib/5.6.1
      2. use lib:
        use lib qw(/opt/perl5/lib/5.6.1);
        (this also works in a module, of course)
      Use either, not both!

      Either is preferable to manipulating @INC directly: it's clearer, and you get nicer behaviour simpler (e.g. beatnik's and Azatoth's code above adds the new directory as the last directory to be searched; you'd usually want to search it first).

Re: perl cant find it anymore!
by Beatnik (Parson) on Jun 18, 2001 at 18:55 UTC
    push(@INC,"/opt/perl5/lib/5.6.1"); #could do the trick.

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
      I noticed this problem further down the page after I posted this....I see it is not just myself that is having a problem....does HP11.11 not play nice with perl or something? and I cant do your fix just yet, because I am also having a problem with the @ symbol...seems I cant type it on this friggen system....it kind of acts like a Ctrl-W key or something...it is really messed up *sigh*
        Your @ woes are UN*X-related, not Perlish.
        You know it's a UNIX system when backspace does something else.
        In your case, stty sane (typed at the shell!) should fix things). If not, stty werase ^w should help.

        Bonus old fart points for remembering which key deletes just one character!

Re: perl cant find it anymore!
by toma (Vicar) on Jun 18, 2001 at 21:03 UTC
    Yes, there is such a config file, and if you move things around it will point to the wrong place and not be able to find modules. Also, you will have trouble installing new modules. The file is called Config.pm, and is located in a directory somewhere like /opt/perl5/lib/5.6.0/PA-RISC2.0. It is created in the 'Configure' step when perl is compiled.

    Update: As noted below you can't fix this with hand-editing. You can find out what your INC path is with perl -V.

    Much better is to put perl where Config.pm expects it to be, or recompile perl. You need the ANSI C compiler to compile perl on HP-UX, though.

    You can see what is in Config.pm by inspecting the code in the module, or with this code:

    #!/opt/perl5/bin/perl use strict; use Config; for (keys %Config) { print "$_ = $Config{$_}\n"; }

    You can use the INC path methods above to get the use Config line to work.

    It should work perfectly the first time! - toma

      You should recompile Perl not because Config.pm is hard to edit by hand but because the values for @INC are compiled into the perl binary, not read from Config.pm! Otherwise, how would Perl find Config.pm? (:

      Now, MakeMaker does read Config.pm so you can affect where modules get installed by modifying that file.

              - tye (but my friends call me "Tye")
Re: perl cant find it anymore!
by feloniousMonk (Pilgrim) on Jun 18, 2001 at 22:25 UTC
    --
    Instead of trying to change @INC, I would just place
    your modules in the existing @INC - This way you won't
    have some "rogue" modues floating around in an obscure
    corner somewhere.

    Unless a decision was made to change @INC and put all new
    modules there. In this case, I would recompile Perl with the updated @INC.

    -felonious

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://89313]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-25 20:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found