Perl arrays
Something that we can make use of in Perl is an array. These arrays are variables that are created from lists; put simply, they are basically multi-valued variables. If we were to use a container analogy to describe a variable, it will be either a cup or a placeholder for one value. An array will be analogous to a crate. We can describe the crate with a single name but we have to include additional naming elements to access each slot within the crate. A crate can hold more than a single item, just like an array.
We saw that by using bash scripting we can pass command line arguments in the script. The arguments were using their own variable name, $1
, $2
, and so on. This also clashed with the name of the program, to a degree, because of the fact that it was $0
. Even though they may appear similar, there is no logical relationship between $0
and $1
. The $0
variable is the name of the script and $1
is the first argument. When we look at this in Perl, we can start to see some of the...