Learning a new language is difficult, partly because you sometimes must use the language to explain the language.
There are examples in this course
that use language elements that have not yet been thoroughly explained.
Variables are nothing but reserved memory locations to store values.
When you create a variable you reserve some space in memory.
Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory.
Therefore, by assigning different data types to variables, you can store integers, decimals, or strings in these variables.
Perl has following three basic data types:
Accordingly we are going to use three types of variables in Perl.
A scalar variable will be preceded by a dollar sign ($) and it can store either a number, a string, or a reference.
An array variable
will be preceded by the @ symbol and it will store ordered lists of scalars.
The hash variable
will be preceded by the % symbol and will be used to store sets of key/value pairs.
Perl maintains every variable type in a separate namespace
You can use the same name for a scalar variable, an array, or a hash.
This means that $foo and @foo are two different variables.