Coding Gotchas

From Dreamwidth Notes
Revision as of 20:39, 8 March 2011 by Exor674 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page has a list of random weird Perl and DW gotchas

Gotchas

use strict + my $foo if

use strict;
 
my $x = -1 if 0; # this condition is supposed to fail.
$x = 1; # This accesses a *global, persistant across requests* $x

strict does not complain about this.

Do the following instead

use strict;
 
my $x;
$x = -1 if 0;
$x = 1;