Recall that unshift places its arguments onto the array in order as they are listed in the function call. The moral here is to be careful when using unshift in this manner, since it places it arguments on the array in order . It may have occurred to you by now that in certain places we can use a list, and in other places we can use a scalar. Perl knows this as well, and decides which is permitted by something called a context . The context can be either list context or scalar context.
Many operations do different things depending on what the current context is.
When you do this, the array variable evaluates to the number of elements in the array. You must always be aware of the context of your operations. Assuming the wrong context can cause a plethora of problems for the new Perl programmer. Array Interpolation Array variables can also be evaluated through interpolation into a double-quoted string. When an array variable is encountered in a double-quoted string, Perl will join the array together, separating each element by spaces.