Predefined Variables
Next: Command Line Options
Up:
Previous: Packages
Perl has a sizable set of predefined variables. These are all documented
in detail in the man pages so I will only describe a few of the common
ones.
- $_
- Default argument for many routines and syntactic
structures.
- $?
- Status word returned from last system call. The lower
bytes contain the signal upon which the program died (if any) and the upper
bytes contain the exit code.
- $$
- Process ID of script.
- $<
- Real user ID of user running script.
- @ARGV
- Command-line arguments of script. Note that $ARGV[0] is the first actual argument, not the name of the program (as in
C). The name of the script is in the variable $0.
- %ENV
- Associative array containing the environment variables
of the calling environment.