HTML CSS PHP PERL

Workshop

 
Previous Table of Contents Next

Workshop

Quiz

1:

What were the bugs in the Listing 12.1?

2:

If no files are given on the command line, reading <> returns

  1. undef

  2. lines from standard input

  3. True

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.)

  1. Use the T command, for trace

  2. Use the t command, for trace

Answers

A1:

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.

    Previous Table of Contents Next
    © 2000- NIV