Perl has three different kinds of variables:
-
scalar variables, whose names begin with a $,
as in $name
-
array variables, whose names begin with a @,
as in @my_relatives
-
hash variables, whose names begin with a %,
as in %phone_book
Variables are declared implicitly by when first encountered.
Variables declared implicitly (even in functions) are global.
Unassigned scalar variables have the value undef, which
has a numeric value of 0 and a string value of "".
Variable names are case-sensitive and, after the first character,
contain letters, digits and/or underscores.
Perl has many built-in "implicit" variables, among the most
useful of which are $_ and @_,
which represent the "default scalar variable" and the "default
array variable", respectively, as well as @ARGV, the array
of command-line arguments.