Putting Things into Lists and Arrays
Putting things into a literal list is easy. As you just saw, the syntax for a literal list is a set of parentheses enclosing scalar values. The following is an example:
(5, 'apple', $x, 3.14159)
This example creates a four-element list containing the numbers 5, the string 'apple', whatever happens to be in the scalar variable $x, and pi.
If the list contains only simple strings, and putting single quotation marks around each string gets to be too much for you, Perl provides a shortcut—the qw operator. An example of qw follows:
qw( apples oranges 45.6 $x )
This example creates a four-element list. Each element of the list is separated from the others by whitespace (spaces, tabs, or newlines). If you have ...