Workshop
Quiz
1: | What were the bugs in the Listing 12.1? | 2: | If no files are given on the command line, reading <> returns
lines from standard input
| 3: | The Perl debugger can print Perl statements as they execute. This is called trace mode. How do you put the debugger into trace mode? (Hint: You need to look at the debugger's help message for this answer.)
Use the T command, for trace Use the t command, for trace
|
AnswersA1:
| First, in line 15 the range (20..0) is not valid. The range operator—..—does not count down, only up. This line should be changed to a for($_=20; $_>-1; $_--) loop, reverse(0..20) or something similar. Second, at line 10 the $mess=s/glasses/glass/ looks like a substitution on $mess, but it's not. The substitution is actually getting performed on $_ because the assignment (=) should actually be a bind (=~). | A2:
| b. If no filenames are given, <> begins reading STDIN. | A3:
| b. The t command prints all your program's statements as they execute. The T command prints a stack trace, which is a listing of what function is currently being executed, the function that called that function, the function that called that function, and so on. |
|