DocTaur - intranet directory of reference manuals
Yo-store
books for webmasters

reference manuals search engine

Perl Tutorial Book

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

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 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 example:

 
use strict;
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.


This document was generated on July, 31 2004 using texi2html 1.70.