
| Contents |
|||||||||||||||
| [an error occurred while processing this directive] |
3.3.1 Array VariablesEach variable in Perl starts with a special character that identifies what type of variable it is. We saw that scalar variables always start with a `$'. Similarly, all array variables start with the character, `@', under the same naming rules that are used for scalar variables. Of course, we cannot do much with a variable if we cannot assign things to it, so the assignment operator works as perfectly with arrays as it did with scalars. We must be sure, though, to always make the right hand side of the assignment a list, not a scalar! Here are a few examples:
use strict; my @stuff = qw/a b c/; # @stuff a three element list my @things = (1, 2, 3, 4); # @things is a four element list my $oneThing = "all alone"; my @allOfIt = (@stuff, $oneThing, @things); # @allOfIt has 8 elements!
Note the cute thing we can do with the |