Data Types and Variables
Perl has three basic data types: scalars, arrays, and hashes.
Scalars are essentially simple variables. They are preceded by a
dollar sign ($). A scalar is either
a number, a string, or a reference. (A reference is a scalar that
points to another piece of data. References are discussed later in
this chapter.) If you provide a string in which a number is expected
or vice versa, Perl automatically converts the operand using fairly
intuitive rules.
Arrays are ordered lists of scalars accessed with a
numeric subscript (subscripts start at 0). They are preceded by an
“at” sign (@).
Hashes are unordered sets of key/value pairs accessed
with the keys as subscripts. They are preceded by a percent sign
(%).
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access