go ahead... be a heretic | |
PerlMonks |
Detecting 'our $foo => 1' mistake?by perlancar (Hermit) |
on Jan 21, 2017 at 09:58 UTC ( [id://1180074]=perlquestion: print w/replies, xml ) | Need Help?? |
perlancar has asked for the wisdom of the Perl Monks concerning the following question: Dear monks, I just wasted half an hour trying to find a cause why a variable is undefined (and chasing the wrong rabbit of trying to figure out why a particular module won't load but require() doesn't raise an error), before finally realizing that I made a typo: our $foo => { a=>'blah', b=>'blah', ... }; instead of: our $foo = { a=>'blah', b=>'blah', ... }; And come to think of it, this is perhaps my third or fourth time being bitten by this. This mistake is not caught by warnings, so any suggestion on how to detect this? Perhaps there's a Perl::Critic policy somewhere and I need to just (re-)plunge and use Perl::Critic (again). UPDATE 2017-01-23: my bad, it turns out I didn't use warnings in the original code. our $foo => value indeed produces warning in most cases.
Back to
Seekers of Perl Wisdom
|
|