Perl Programming/Data types
Appearance
Perl has four fundamental data types: scalars, lists, hashes, and typeglobs.
- 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.
- typeglob
- is a variable representing an entry within the internal symbol table. It is used to manipulate file handles, and to create references or aliases.
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
*foo # a typeglob