Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: perl cant find it anymore!

by azatoth (Curate)
on Jun 18, 2001 at 19:06 UTC ( [id://89323]=note: print w/replies, xml ) Need Help??


in reply to perl cant find it anymore!

You'll want to put beatnik's comment in a BEGIN block though, to ensure it's sorted before we start the getting to the nuts and bolts of things.

BEGIN { push(@INC,"/opt/perl5/lib/5.6.1"); } #rest of code follows


Azatoth a.k.a Captain Whiplash

Make Your Die Messages Full of Wisdom!
Get YOUR PerlMonks Stagename here!
Want to speak like a Londoner?

Replies are listed 'Best First'.
Re: Re: perl cant find it anymore!
by ariels (Curate) on Jun 18, 2001 at 19:42 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).

Log In?
Username:
Password:

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

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

    No recent polls found