Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^2: On Commenting Out 'use strict;'

by talexb (Canon)
on Aug 11, 2005 at 02:22 UTC ( #482838=note: print w/replies, xml ) Need Help??

in reply to Re: On Commenting Out 'use strict;'
in thread On Commenting Out 'use strict;'


Those PITA warning messages are little hints that the craftmanship of the code is below par. Perhaps one in a thousand warnings can be ignored. The other 999 need to be addressed. An example.

Yesterday and today I had to write quick scripts to get some stuff done on a Production system. Normally I'd do a one-liner or cobble something absolutely horrible together, cross my fingers and go with it.

Instead, I wrote POD, used Getopt::Long to handle arguments, used or die $usefulMessage in all of the appropriate places. Yes, it took a little longer to write, and I tested as I went .. but the result was that these little utilities worked absolutely fine. Then what?

Then I checked them into our version control system so that I would know where to find them the next time I needed them. So now I have documented, commented, error checking utilities that I can pull out of my hat (so to speak) the next time we need to do X.

It all comes down to a matter of craftmanship. If my scripts and modules compile 100% clean, if I never have errors in my error logs, that's a sweet way to be.

So fix your code -- banish all warnings!

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

Replies are listed 'Best First'.
Re: On Commenting Out 'use strict;'
by jonadab (Parson) on Aug 11, 2005 at 09:59 UTC

    I think it's a little worse than that. There are a couple of warnings in Perl5 that frequently get triggered without any real problem in the code. I'm thinking most especially of the one when you interpolate a value that might or might not be defined, and it happens not to be. I have never yet once seen a situation where that warning was useful, but many, many times I have found myself introducing excessive verbosity and needless complexity to the code in order to suppress it.

    I've also occasionally been annoyed by other warnings when I knew very well about the thing they were warning about but for one reason or another did not consider it a problem, and I wished I could just make the warning shut up.

    I heard a rumor that Perl6 is going to give us the ability to shut off individual warnings, without losing the ability to see other warnings. I look forward to that.

    Nevertheless, the clown described in the original post is making future trouble for himself and/or someone else.

      I heard a rumor that Perl6 is going to give us the ability to shut off individual warnings, without losing the ability to see other warnings.

      You can actually do that on Perl 5:

      use warnings; ... # and then deep on your code { ... no warnings 'uninitialized'; # or whatever print "$uninitialized_var\n"; ... }
        Just to shine a little more light on it: perllexwarn. Search for 'Category Heirarchy' if you want to see all of the categories.


        Feel the white light, the light within
        Be your own disciple, fan the sparks of will
        For all of us waiting, your kingdom will come

      I have run into more than one situation in maintaining code (one other developer, specifically) that started throwing a lot of warnings when he turned on warnings where the warning was quite useful. This person found that the best way to get rid of these "useless" "unitialized" warnings was to pipe his error logs through grep -v uninitialized. (He was not at the company six months later.) When I went into the code, I found that he was testing against a typoed hash key. This was a subtle bug that was not discovered for *YEARS* until warnings were turned on.

      Ivan Heffner
      Sr. Software Engineer, DAS Lead, Inc.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://482838]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2017-03-30 03:54 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (353 votes). Check out past polls.