Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: RFC: Tutorial: use strict; now what!?

by Eliya (Vicar)
on Feb 08, 2012 at 17:43 UTC ( #952535=note: print w/ replies, xml ) Need Help??


in reply to Re^2: RFC: Tutorial: use strict; now what!?
in thread RFC: Tutorial: use strict; now what!?

Lumping strict and warnings together is a mistake.

I beg to disagree.  Many times (not only here, but at my workplace, too) I've seen people hunting for bugs for way too long, simply because they thought "I don't need no stinking warnings".  Had they had them enabled, they would have been pointed to the root cause of the problem more or less directly.   And if you feel annoyed by the "use of uninitialized value"s (and you know what you're doing), it's no big deal to disable those specifically with no warnings "uninitialized"; — at least that doesn't qualify as "a lot of work" in my opinion.

I agree there are rare circumstances where you don't want them — for example, I've seen a few cases (very few actually) where leaving warnings enabled in production environments has led to more problems than it solved — but as a development tool, I'd always recommend use warnings;


Comment on Re^3: RFC: Tutorial: use strict; now what!?
Select or Download Code
Re^4: RFC: Tutorial: use strict; now what!?
by educated_foo (Vicar) on Feb 08, 2012 at 18:02 UTC
    The solution is pretty simple: if your code isn't doing what you expect, run it with "perl -w". This may point to your error (along with a bunch of other non-errors); if it does, you can fix it and move on without having to contort your code to placate warnings.

      Well, "perl -w" is "enabling warnings", too.   I don't specifically care whether people use "use warnings", "-w" on the command line, or "-w" on the shebang line, as long as they do enable warnings when appropriate.

        "When appropriate" is key. strict is useful (or at least harmless) most of the time; warnings is harmful more often, and useful less often. My point is that warnings can be helpful for finding bugs, but can also force you to change working code for no good reason. Don't use warnings; unless you understand what it does.

        EDIT: Whee! Let's play the downvote game! If you want upvotes, it's important to follow Perlmonks dogma.

      This may point to your error (along with a bunch of other non-errors);...

      ... and a bunch of warnings in other places that aren't under your control. warnings has a lexical scope, while -w and -W affect the entire process.

        ...and? Let's say you tried to log something undefined, so you passed it to your logging module. With "use warnings", you would see nothing; with "-w", you would get a message. Which do you prefer? (Or, perhaps, which is more "Modern"?)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://952535]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (12)
As of 2014-09-30 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (384 votes), past polls