Perl Programming/Data Types
From Wikibooks, the open-content textbooks collection
Perl has three fundamental data types: scalars, lists, and hashes.
- scalar
- is a funny way of saying a single value; it may be a number, a string, or a reference.
- list
- is an ordered collection of scalars. A variable that holds a list is called an array. Items in a list or array can be accessed by their position in the list; programs can retrieve the first, second, third, etc. item in a list.
- hash
- is like an array, in that a hash holds many values, but the values are identified by a unique "key", rather than an ordinal index position.
All variables are marked by a leading sigil, which identifies the data type. The same name may be used for variables of different types, without conflict.
$foo # a scalar @foo # a list %foo # a hash

