At this point, we’re going to go on
Monday, October 30th, 2006At this point, we’re going to go on a tour of typo examples with different diagnoses. 8.2.1 Quotable Quotes Our first program sets up a hash %quotation indexed by author and then goes on: while (my ($author, $quote) = each %quotation) { print ‘Quote of the Day: “$quote” by $authorn’; } This runs, but takes us too literally: Quote of the Day: “$quote” by $authornQuote of the Day: “$quote” by $authornQuote of the Day: “$quote” by $authorn… Aha! Nothing is being interpolated because we’re using single quotes. We change them to double quotes: 3 while (my ($author, $quote) = each %quotation) 4 { 5 print “Quote of the Day: “$quote” by $authorn”; 6 } Yikes, now we get three errors: Scalar found where operator expected at typo.pl line 4, near “”Quote of the Day: “$quote” (Missing operator before $quote?) syntax error at typo.pl line 4, near “”Quote of the Day: “$quote” String found where operator expected at typo.pl line 4, near “$quote” by $authorn”" (Missing operator before ” by $authorn”?) Execution of typo.pl aborted due to compilation errors. Once again, we consider only the first message. Whenever Perl provides a hint after the error, read it carefully. Perl suggests that we omitted an operator before $quote, but why would it expect an operator in the middle of a string? Aha we must not be in a string any more. At this point I would have pointed out that the syntax coloring feature of Emacs cperl mode would have shown this, but I promised Ed not to make fractious text editor advertisements.
Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra servlet hosting services
Posted in perl | No Comments »