Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Using modules without admin privelages

by illsorted (Scribe)
on May 05, 2000 at 22:21 UTC ( [id://10403]=perlquestion: print w/replies, xml ) Need Help??

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

I'm using perl 5.002 on a Unix machine, but no modules are installed. I'm not the system administrator, and because the machine belongs to the University I attend, the administrator is not very responsive to adding/updating modules. My question is this: Is there a way to tell perl to look in my home directory for modules instead of the default directory? Thanks

Replies are listed 'Best First'.
Re: Using modules without admin privelages
by btrott (Parson) on May 05, 2000 at 22:22 UTC
    Yes. The easiest way is to add this to the top of your Perl script that uses the module:
    use lib '/home/foo';
    This will tell perl to look in /home/foo for modules.

    Another option is to use the -I flag on your #!/path/perl line:

    #!/usr/local/bin/perl -w -I/home/foo
    A final option is to set the PERL5LIB environment variable to the path.

    Personally, I'd recommend using the first option (use lib).

    If you're trying to *install* modules into your home directory, run Makefile.PL with the PREFIX option:

    perl Makefile.PL PREFIX=/home/foo
    And if you're using CPAN.pm, specify PREFIX=/home/foo as the argument to Makefile.PL in the configuration options when you first run the shell.
Re: Using modules without admin privelages
by ZZamboni (Curate) on May 05, 2000 at 23:59 UTC
    I will disagree with chromatic and btrott and say that I prefer to set the PERLLIB or PERL5LIB environment variable to the path where my modules are installed. Why? Because then you don't need to modify existing scripts to add the 'use lib' directive. The additional directories will be searched automatically.

    Also, if you "use lib" and later you need to move your modules directory for some reason, you will have to go modify all your scripts. If you use the environment variable, you just have to change one place and all your scripts will keep happily running.

Re: Using modules without admin privelages
by chromatic (Archbishop) on May 05, 2000 at 22:59 UTC
    In the interests of completeness, the other two options are:
    BEGIN { push @INC, '/home/foo'; }
    and setting PERLLIB. (If you have PERL5LIB defined already -- and you almost certainly do -- this environmental variable will be ignored.)

    Use 'use lib'.

RE: Using modules without admin privelages
by Anonymous Monk on May 05, 2000 at 23:39 UTC
    I would simply append "/home/directory" to @INC. -lf

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-18 02:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found