Environment Variables
Environment variables are used to set user preferences. Individual Perl modules or programs are always free to define their own environment variables, and there is also a set of special environment variables used in the CGI environment (see Chapter 9).
Perl uses the following environment variables:
- HOME
Used if
chdirhas no argument.- LOGDIR
Used if
chdirhas no argument and HOME is not set.- PATH
Used in executing subprocesses and in finding the script if -S is used.
- PATHEXT
On Win32 systems, if you want to avoid typing the extension every time you execute a Perl script, you can set the PATHEXT environment variable so that it includes Perl scripts. For example:
C:\> set PATHEXT=%PATHEXT%;.PLX
This setting lets you type:
C:\> myscript
without including the file extension. Be careful when setting PATHEXT permanently—it also includes executable file types such as .com, .exe, .bat, and .cmd. If you inadvertently lose those extensions, you’ll have difficulty invoking applications and script files.
- PERL5LIB
A colon-separated list of directories in which to look for Perl library files before looking in the standard library and the current directory. If PERL5LIB is not defined, PERLLIB is used. When running taint checks, neither variable is used. The script should instead say:
use lib "/my/directory";
- PERL5OPT
Command-line options (switches). Switches in this variable are taken as if they were on every Perl command line. Only the -[DIMUdmw] switches are allowed. When running taint checks, ...
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