in reply to Re: Common uses of "use" (warnings?)
in thread Common uses of "use"

I also typically do a "perl -wc" check on the script to identify issues between the keyboard and chair. However, I usually have a use warnings statement in the code itself, which complains a lot with data-related issues e.g. string concatenation with un-initialised values.

So, given that I perform the integrity check on the script first, is including this pragma as a matter of habit actually doing anything for me, other than generating lots of data-related warnings?

Obviously, there ARE situations when you want to get these warnings, depending on the situation, but I'm leaning towards not including by default - or maybe, like diagnostics, using it when initially testing out the script, but then comment it out?

Replies are listed 'Best First'.
Re^3: Common uses of "use" (warnings?)
by tye (Sage) on Oct 28, 2010 at 13:56 UTC
    Obviously, there ARE situations when you want to get these warnings,

    Just to be clear, I usually use #!/usr/bin/perl -w (as the first line of each script) which means that I get more warnings than I would if I used use warnings;.

    Users of a script usually don't have many ways of giving the script undefined values so the line between "script user" and "script" is not the same as the line between between "module user" and "module" with regard to warnings. If I test a script well, then I usually won't leave it up to the script user to launch via "perl -w ..." in order to get warnings.

    However, for scripts that get run other than by other either developers or IT workers, I do indeed sometimes leave warnings turned off when the script is deployed. Warnings seen by a non-technical user or written to a Production log file are very often worse than useless. The lower the odds of "the warning making it back to a developer along with sufficient information for the cause of the warning to be identified so the code can be fixed to eliminate the warning (and perhaps a bug that the warning detected)", the less value there is to leaving warnings enabled.

    - tye