3.4.4 Array Interpolation
Array variables can also be evaluated through interpolation into a
double-quoted string. This works very much like the interpolation of
scalars into double-quoted strings (see section 2.3.1 Scalar Interpolation). When
an array variable is encountered in a double-quoted string, Perl will
join the array together, separating each element by spaces. Here is an
my @saying = qw/these are a few of my favorite/;
my $statement = "@saying things.\n";
# $statement is "these are a few of my favorite things.\n"
my $stuff = "@saying[0 .. 1] @saying[$#saying - 1, $#saying] things.\n"
# $stuff is "these are my favorite things.\n"
Note the use of slices when assigning
$stuff. As you can see,
Perl can be very expressive when we begin to use the interaction of
different, interesting features.