in reply to Do people find warning for undef with string compare useful?

Yes to the headline question. I've probably disabled it 3 or 4 times in (a guess) 25,000 scripts I've written.

And then only temporarily until I worked out the proper way to prevent the warning rather than silence it.

How do people find the warning useful for 'eq'/'ne'?

Simple. If one of the variables in a comparison is undef, I either typoed, or I forgot to initialise it. A case of a class 1 beginner's error that I still make after 30 years doing this.

And that warning tells me I made it (again), the first time I run the code; rather than it languishing as a latent bug that Sod's Law says will strike at exactly the worst moment.

Anyone who disables it de rigor; or worse, skips warnings altogether as too much work, is simply kidding themselves.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: Do people find warning for undef with string compare useful?

Replies are listed 'Best First'.
Re^2: Do people find warning for undef with string compare useful?
by perl-diddler (Chaplain) on Jun 01, 2013 at 01:59 UTC
    Yes to the headline question. I've probably disabled it 3 or 4 times in (a guess) 25,000 scripts I've written.
    I don't know how to disable the warning for only the "eq" and "ne" operators. How do you do it without affecting other messages?
      { local $^W; # expression or statement using eq or ne (or lt or le or gt or ge + or cmp) here }

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        I think you missed the world "*only*" for the eq/ne operators.

        I'm looking more for a scalpel, not TNT. ;-)