Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

ADD PATH TO @INC

by athar-qadri (Initiate)
on Jun 18, 2001 at 22:06 UTC ( #89384=perlquestion: print w/ replies, xml ) Need Help??
athar-qadri has asked for the wisdom of the Perl Monks concerning the following question:

Dear all Kindly give me the answer about how to add paths like c:\ads\lib in @INC Thanks in advance Syed Hussain

Comment on ADD PATH TO @INC
Re: ADD PATH TO @INC
by damian1301 (Curate) on Jun 18, 2001 at 22:09 UTC
    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.
      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

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

        :-)

      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";
Can @INC be modified using environment variables in Win?
by yudel (Novice) on Jun 19, 2001 at 01:19 UTC
    A related question: I'd like to add a directory to @INC globally, without changing my programs.

    Can it be done using an environment variable in Win?

    Or perhaps some other way?

    Larry

      In Windows, the starting path is stored in the registry, but not really documented as to where -- you can find it if you look, though. In general, you can use an environment variable (PERL5LIB I think) which is combined with that starting path.
        John,

        Thanks! I actually just found this in the Perl Cookbook.

        set PERL5LIB=e:\whatever\whatever
        works as advertised.

        No, in Win32 Perl, the starting value of @INC is computed based on the path to the running perl.exe. Some versions of Win32 Perl also look in the Registry.

                - tye (but my friends call me "Tye")
      Hi,

      The 'set' command will work for a given cmd window (or always, if you run it in a batch file or 'system' call at the beginning of the script).

      If you want to set it permanently, go to:
      control panel->system->advanced->environment variables
      and set PERL5LIB there. (This is on Win2K, but if I recall it's the same on NT4)

      - perchance

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-12-20 10:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (95 votes), past polls