2 Qs XML(loosly) and reinventing the wheel

Austin Schutz tex at off.org
Thu Feb 14 17:07:08 CST 2002


> > The first step type, use strict, save,
> > run, clean up all errors...hehe.  Another thing I've noticed is that
> > delving into someone else's code has helped me learn a fair amount.  Get
> > an alternative perspective.  I guess the code isn't all that ugly
> > realy...I'm just used to use strict.
> 
> Good for you!  Damian Conway gets away with not using strict.  Mark-Jason
> Dominus gets away with not using strict (he actually has stated that it's
> over-rated).  Many people would even be surprised to discover that CGI.pm
> does not use strict.
> 
> Unless a programmer can legitimately claim to be on par with them, they
> should probably be using strict.  Oh, I'm not saying for a one-liner or a
> throw-away script to analyze logs must have strict.  I'm talking about real
> programs that are likely to be re-used.
> 

	I use strict in my code religiously. Here's one example of how
it saves my bacon:
	Occasionally I forget something like my($html); at the top of a sub,
particularly a long and complex one, e.g:

#use strict

sub text_to_html_header {
  my($string) = shift;
  $html .= "<h1>$string</h1>";
  return $html;
}

	Now, since $html is a package scoped variable by default, every
time you run this sub the return will get larger and larger. This is
obviously quite simplified, but this kind of error can be infuriating to
try to find and often quite confusing in symptom. use strict totally
trivializes debugging:

Global symbol "$html" requires explicit package name at test.pl line 7.
Global symbol "$html" requires explicit package name at test.pl line 8.
Execution of test.pl aborted due to compilation errors.


	I'm not sure what the performance penalty is for use strict. I
have been known to use it for testing, then leave it off in working code.


	Austin
TIMTOWTDI



More information about the Pdx-pm-list mailing list