Environment Variables
In addition to the various switches that explicitly modify Perl’s behavior, you can set various environment variables to influence various underlying behaviors. How you set up these environment variables is system dependent, but one trick you should know if you use sh, ksh, or bash is that you can temporarily set an environment variable for a single command, as if it were a funny kind of switch. It has to be set in front of the command:
$ PATH='/bin:/usr/bin' perl myproggieYou can do something similar with a subshell in csh and tcsh:
% (setenv PATH "/bin:/usr/bin"; perl myproggie)Otherwise, you’d typically set environment variables in some file with a name resembling .cshrc or .profile in your home directory. Under csh and tcsh you’d say:
% setenv PATH '/bin:/usr/bin'And under sh, ksh, and bash you’d say:
$ PATH='/bin:/usr/bin'; export PATHOther systems will have other ways of setting these on a semipermanent basis. Here are the environment variables Perl pays attention to:
HOMEUsed if
chdiris called without an argument.LC_ALL,LC_CTYPE,LC_COLLATE,LC_NUMERIC,PERL_BADLANGEnvironment variables that control how Perl handles data specific to particular natural languages. See the online docs for perllocale.
LOGDIRUsed if
chdirhas no argument butHOMEis not set.PATHUsed in executing subprocesses and for finding the program if the –S switch is used.
PERL5DBThe command used to load the debugger code. The default is:
BEGIN { require "perl5db.pl" }See Chapter 18 for more ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access