Collections and control flow

This part holds the containers and the branches: arrays and hashes with the functions that grow, cut and invert them, the context that decides what an expression returns, and the conditions, loops and foreach that walk the data.

3.1 Arrays ordered lists, elements by index, slices, and lists built with ranges and qw Open 3.2 push, pop, shift and splice grow and shrink an array at either end, cut a range out with splice, and reverse a list Open 3.3 Hashes key-value pairs, values read and written by key, the fat comma, and the autovivification trap Open 3.4 keys, values, exists and delete walk a hash, test membership, remove an entry, and invert a hash Open 3.5 Scalar and list context the context an operator sees, scalar to force it, and a subroutine that reports what the caller wanted Open 3.6 Conditions and comparison if, elsif and unless, the ternary operator, and the values Perl treats as true Open 3.7 while, for, next and last while and until, the C-style for loop, next, last and a labelled block Open 3.8 foreach and the default variable walk a list with foreach, use $_, change an element through the alias, and name the variable when the block grows Open

Lessons