2.1. List Operators
You already know about several list operators
in Perl, but you may not have thought of them as working with lists. The most common list operator is probably print. We give it one or more a...
2.2. Trapping Errors with eval
Many lines of ordinary code have the potential to terminate a program prematurely if something goes wrong.
my $average = $total / $count; # divide by zero?
print "okay\n" unless /$match/; ...
2.3. Dynamic Code with eval
There's also a second form of eval, whose parameter is a string expression instead of a block. It compiles and executes code from a string at runtime. While this is useful and supported, it is also dangerous...
2.4. Exercises
You can find the answers to these exercises in "Answers for Chapter 2" in the Appendix.
2.4.1. Exercise 1 [15 min]
Write a program that takes a list of filenames on the command line and uses grep to select the ones whose size in...