[Buffalo-pm] Learning Perl

Shaun Griffith sgriffit at gennum.com
Thu Sep 2 17:04:51 CDT 2004


Ganesh Shankar wrote:
> When, I'm stuck, I google the error message and usually get some relevant
hits.

	use diagnostics;

is sometimes helpful, giving out expanded info on error messages. These are
also a must:

	use strict;
	use warnings;

[Some will complain, but if you don't know why to turn them off, and where,
then you probably shouldn't.]

Line numbers in error messages are rough guesses. Sometimes the real error
is before or after (could be many lines away, depending on the structures
involved). Sometimes the error message is misleading, and you're really
missing a closing paren/brace/bracket, or semicolon. [My most frequent error
seems to be:

	syntax error at q.pl line 5, near "my "
	Global symbol "$y" requires explicit package name at q.pl line 5.

which is caused by "my $x = 1" not having a semicolon, but is immediately
followed by "my $y = 2;"]

The command line debugger (perl -d scriptname) is a powerful tool. Use it to
verify that you are getting the behavior you expect (variables, flow
control). Or you can use ptkdb, the Perl/Tk visual debugger.



More information about the Buffalo-pm mailing list