Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris


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';
$_.=($=+(6<<1));print(chr(my$a=$_));$^H=$_+$_;$_=$^H; print chr($_-39); # Easy but its ok.

Replies are listed 'Best First'.
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.


        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!


by tye (Sage) on Jun 18, 2001 at 23:11 UTC

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

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

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://89386]
and the monastery is silent...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2018-06-23 08:56 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.