Summary

Today was list day. As you learned, a list is just a bunch of scalars, separated by commas and surrounded by parentheses. Assign it to an array variable @array, and you can then get at the individual elements of that array using array access notation $array[index]. You also learned about finding the last index in the array ($#array), and the number of elements in the array ($elements = @array). We finished up that section with a couple of notes on list syntax and assignment, which allows you to assign variables to values in parallel in lists on either side of an assignment expression.

After arrays, we tackled context, which allows Perl to evaluate different things differently in either scalar or list context. You learned the three questions ...

Get Sams Teach Yourself Perl in 21 Days, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.