Predefined Variables
Perl has a number of predefined variables that resemble gibberish. There is an arguement that these variables usually have a mnemonic that makes sense but this is debatable. :-) I'll only mention a few of them here since there are many.
The following list consists of a predefined variable and its English equivalent (if any). Inside the []'s will be the mnemonic as suggested by the Perl documentation or from the Camel Book (see references). Note: to be able to use the English equivalents you must specify 'use English;' at the top of your perl program.
$_ is probably the most commonly used special variable. It is the default input and pattern-searching space. That is, $_ gets set or is acted on by default if left out of the following examples:
while (<>) { blah blah }With $_, those would have looked like:
while ($_ = <>) { blah blah }$_ works like this in many places. [mnemonic: underline is understood to be underlying certain undertakings]
$$ represents the current process id of the running perl script. [mnemonic: just like in shells scripts] English: $PID, $PROCESS_ID
$0 contains the name of the running perl script. Don't get this confused with ARGV[0] later which means something different. [mnemonic: just like Bourne and Korne shells] English: $PROGRAM_NAME
$ARGV contains the name of the current file when reading from <>. (<> treats @ARGV as filehandles)
@ARGV is an array containing a list of command line arguments passed to the perl script. $ARGV[0] is the first arguement (and is not the name of the running perl script). $#ARGV is the number of command line arguements minus one (so it's really the last index of @ARGV).
Note that there are many many more predefined, special variables. These just touch the surface.