Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: ADD PATH TO @INC

by damian1301 (Curate)
on Jun 18, 2001 at 22:09 UTC ( #89386=note: print w/ replies, xml ) Need Help??


in reply to ADD PATH TO @INC

You push it into @INC or you use lib. This was answered not even 5 minutes ago in another question.

BEGIN{push @INC, 'C:\ads\lib';} or use lib 'C:\ads\lib';
UPDATE:doh
$_.=($=+(6<<1));print(chr(my$a=$_));$^H=$_+$_;$_=$^H; print chr($_-39); # Easy but its ok.


Comment on Re: ADD PATH TO @INC
Select or Download Code
Re (tilly) 2: ADD PATH TO @INC
by tilly (Archbishop) on Jun 18, 2001 at 22:36 UTC
    Quick, why is the first solution likely to not do what the poster needs? When will it?

    Try to anticipate what questions your answer will lead to. It is similar to what you need to do in anticipating ways in which the code you just wrote is going to lead to problems down the road for you. Both are useful skills up front and lead to continuing improvement down the road...

      The apprentice takes a shot at expanding on D'oh!, just to make sure he's been paying attention...

      Presumeably because push appends the element to the array and use lib prepends it.

      The first would, I think, work when you've installed a module into your local area that is already available in the standard area. Why would you do this? Perhaps you need (want) to use (or experiment with) a later version. Perhaps you're not the admin and the real admin is busy, lazy, or charges you to install stuff. Perhaps the existing one is severely broken for some reason (e.g. a bad install). Perhaps you're trying to make sure your stuff is searched before anything else.

      The latter is, I believe the preferred approach and should be used unless you know why it won't work for you.

      --f

        That and (before damian1301 fixed the main issue) a question of timing. He didn't have a BEGIN block so his push happened at run-time while a use happens at compile time.

        A more subtle point. lib doesn't bother to put its unshift in a BEGIN block and it works just fine. If you were writing a module and you wanted to affect someone's @INC you could ignore the BEGIN and it works. Which works because runtime for a module compile time for anything that uses it.

      But that's not the way to get the most early ++ votes!

      :-)

(tye)Re: ADD PATH TO @INC
by tye (Cardinal) on Jun 18, 2001 at 23:11 UTC

    print "C:\ads\lib";
    prints C:*beep*dsib
    BTW.

            - tye (but my friends call me "Tye")
      You need to escape the backslash with another backslash:

      print "C:\\ads\\lib";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-09-02 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (20 votes), past polls