Loginskip to content

October 30th, 2006

At this point, we’re going to go on

At least we don’t have to look far to find the problem; the string ended prematurely one character before $quote. There is, of course, more than one way to fix it. We could escape the ” inside the string with backslashes, or we could use the spiffy qq operator, which allows us to pick any delimiter to use for a double-quoted string: while (my ($author, $quote) = each %quotation) { print qq(Quote of the Day: “$quote” by $authorn); } 8.2.2 A Capital Typo Our next horror feature is The Program That Wouldn’t Die: #!/usr/bin/perl use Getopt::Std; sub usage { print “Allowable options: -a, -c, -e, -n count, -un”; Exit; } usage() unless getopts(’acen:u’); print “Starting program $0n”; Let’s run it: % typo.pl -q Unknown option: q Allowable options: -a, -c, -e, -n count, -u Starting program typo.pl Why did this program keep going even after it went into the usage error routine? For the answer, this is the last time we’re going to tell you: Put use strictand -w in all your programs! Because when we do, we see: Bareword “Exit” not allowed while “strict subs” in use at typo.pl line 8. Execution of typo.pl aborted due to compilation errors.
Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra servlet hosting services

Comments are closed.