Re: Basic - Perl5lib
by Khen1950fx (Canon) on Oct 27, 2010 at 23:58 UTC
|
| [reply] [d/l] [select] |
|
..and typically you'd set that environment variable so that all your processes/scripts had access to that additional module directory. otherwise just add an additional module directory directly in a perl script by pushing it onto @INC in a begin section. example for modules in specified directory and/or current directory
BEGIN {
$my_module_dir = '~/myperl_modules/`;
push(@INC, ('.',"$my_module_dir"));
}
use mymodule;
...
oracle installs (and embedded) perl and it's own set of modules, and sets perl5lib. so not a good idea to modify perl5lib on oracle systems unless you really know what you're doing.
the hardest line to type correctly is: stty erase ^H
| [reply] [d/l] |
|
The more common way to add to @INC from within your program is with use lib. The following is equivalent to (more concise than) the code above:
use lib qw( . ~/myperl_modules/ );
use mymodule;
...except that use lib puts the extra dirs at the start of @INC (giving them precedence over system modules, which is normally what you want) while your use of push puts them at the end (giving system modules precedence, which is normally not what you want). | [reply] [d/l] [select] |
|
Thanks for your replies. How can I set the PERL5LIB environment variable if I don't have one?
If I do manage to find my missing PERL5LIB, is it shared by all my Perl installations?
| [reply] |
Re: Basic - Perl5lib
by ikegami (Patriarch) on Oct 27, 2010 at 23:00 UTC
|
If you have multiple versions of Perl do they share the same PERL5LIB?
Environment variables are inherited from the parent process.
In other words, it doesn't have a default value and you have to set it manually?
It depends on what you mean by default value. You could set it in your login script, for example.
| [reply] |
|
I don't have a PERL5LIB environment variable?? When i run env command it isn't in the list and I get nothing from this Perl program
#!/usr/bin/perl
print "PERL5LIB: ", $ENV{PERL5LIB}, "\n";
print "done\n";
| [reply] [d/l] |
|
| [reply] |
Re: Basic - Perl5lib
by toolic (Bishop) on Oct 27, 2010 at 23:39 UTC
|
perl does not require that the PERL5LIB environment variable be set. Typically, the variable will not be set to any value.
One common usage scenario is to set the variable to a directory which contains Perl modules that you have developed.
| [reply] |
Re: Basic - Perl5lib
by Anonymous Monk on Oct 28, 2010 at 07:17 UTC
|
You also might be interested in seeing how perlbrew manages switching between different versions. | [reply] |
|
| [reply] |
|
PERL5LIB affects perl processes (every perl process will use PERL5LIB), it doesn't affect installations
| [reply] |