Perl has three basic data types. They are scalars, arrays and hashes. Here are some details about these three datatypes:
- Scalar - Scalars are simple variables. They are preceded by a dollar sign ($). A scalar is either a number or a string.
- Arrays - Arrays are ordered lists of scalars that we access with a numeric index, which starts with 0. They are preceded by an "at" sign (@).
- Hashes - Hashes are unordered sets of key/value pairs that you access using the keys as subscripts. They are preceded by a percent sign (%).
Perl has two types of literals namely Numeric and String literals.
- String Literals - Strings are sequences of characters. They are usually alphanumeric values delimited by either single (') or double (") quotes. Double-quoted string literals allow variable interpolation, and single-quoted strings are not. Commonly used Escape Sequences are:
| Escape Sequence
|| Single Quote
|| Double Qoute
|| New line
|| Carriage Return
|| Vertical Tab
- Numeric Literals - Perl stores all the numbers internally as either signed integers or double-precision floating-point values. Numeric literals are specified in any of the following floating-point or integer formats:
| Negative Integer
| Scientific Notation