Perl Programming/Data Types
Perl has four fundamental data types: scalars, lists, hashes, and typeglobs.
- is a funny way of saying a single value; it may be a number, a string, or a reference.
- 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.
- 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.
- 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
Last modified on 1 December 2012, at 15:22