Built-in Data Types
Before we start talking about various kinds of tokens you can build from characters, we need a few more abstractions. To be specific, we need three data types.
Computer languages vary in how many and what kinds of data types
they provide. Unlike some commonly used languages that provide many
confusing types for similar kinds of values, Perl provides just a few
built-in data types. Consider C, in which you might run into
fp_exception_field_type, and so on. That’s
just some of the integer types! Then there are floating-point numbers,
and pointers, and strings.
All these complicated types correspond to just one type in Perl: the scalar. (Usually Perl’s simple data types are all you need, but if not, you’re free to define fancy dynamic types using Perl’s object-oriented features—see Chapter 12.) Perl’s three basic data types are: scalars, arrays of scalars, and hashes of scalars (also known as associative arrays). Some people may prefer to call these data structures rather than types. That’s okay.
Scalars are the fundamental type from which more complicated structures are built. A scalar stores a single, simple value—typically a string or a number. Elements of this simple type may be combined into either of the two aggregate types. An array is an ordered list of scalars that you access with an integer subscript (or index). All indexing in Perl starts at 0. Unlike ...