[prev] [index] [next]

Variables

Perl supports three kinds of variable:
  • scalars ... a single atomic value (number or string)
  • arrays ... a list of values, indexed by number
  • hashes ... a group of values, indexed by string
Variables do not need to be declared or initialised.

If used when not initialised, the value is 0 or empty string or empty list.

Beware: spelling mistakes in variable names,   e.g.

print "abc=$acb\n";     rather than     print "abc=$abc\n";

prints no value, leaving you wondering what happened to $abc's value.