Getting Elements Out of an Array

So far in this hour, you've been slinging around whole arrays and lists and putting information into arrays. How can you get that information back out?

One way to get the contents of the entire array is to put the array variable in double quotation marks:

print "@array";

An array in double quotes is interpolated, and its elements are returned separated by spaces. This example prints the elements of @array with a space separating each element.

Many times, though, you need to get to individual elements of arrays. You may need to search for an element, change the value of an element, or to add or remove individual elements in an array.

Individual elements in an array are accessed by a numeric index. The index for ...

Get SAMS Teach Yourself Perl in 24 Hours THIRD EDITION now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.