XP is just a number | |
PerlMonks |
Re^5: Shebang behavior with perl (-w)by tye (Sage) |
on Mar 02, 2015 at 22:29 UTC ( [id://1118500]=note: print w/replies, xml ) | Need Help?? |
You are passing an undef into a module that has an unstated (and there is the issue) requirement that the value passed in is not undef. No. A module provides a sub that needs to be passed a string and a number. I pass in undef() for the string and I pass in '42mph' for the number. Those are fine values because I intentionally didn't turn on warnings. But values get passed in to subs as scalars, not as strings or a numbers, so it is inside of the sub that these scalar values get interpreted as a string and as a number. The module's author followed "best practices" (or "cargo cult") and so added "use warnings;". So I get warnings that I didn't ask for and that I don't want. If I wanted to jump through extra hoops to avoid being warned about the nature of these values, then I would have turned on warnings. So I prefer to not "use warnings" in my modules (and to use "-w" in my module tests and even to test that no warnings are emitted in my module tests). In a tool that non-technical people will run, I don't use "-w" (because warnings usually do more harm than good when shown to non-technical people). In most other scripts, I use "-w" and am sometimes glad that I got told about warnings that happened inside of some module (that I didn't write but that still didn't do "use warnings;"). "use warnings" didn't actually solve the problem of "getting unwanted warnings from modules". It just shifted the problem. If I was forced to frequently use a module that generates warnings internally (not just from values I pass in), I'd likely add a $SIG{__WARN__} hook to suppress such and continue to use "-w" (if I was unable to institute a deploy step that adds "no warnings" to each new version of that module), at least so I could continue to get warnings from any non-problematic modules that didn't "use warnings;". Others may choose to use "-X" to deal with unwanted warnings from modules that include "use warnings". Since warnings so often follow data, I find tying warnings to blocks of code to just not be a great approach. - tye
In Section
Seekers of Perl Wisdom
|
|