Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: warnings and strict -- The 2 Best Ways You Can Improve Your Programming

by itub (Priest)
on Oct 04, 2005 at 18:54 UTC ( [id://497358]=note: print w/replies, xml ) Need Help??


in reply to warnings and strict -- The 2 Best Ways You Can Improve Your Programming

If you use warnings, it's usually not a good idea to use -w. When you use the older -w flag, you turn warnings on globally, even in modules you use that were not designed to run with warnings on, so you may get false positives. The warnings pragma gives you finer control, because you can turn the warnings on only where you want, and you can also control the types of warnings you get.

See What's_wrong_with_-w_and_$^W in perllexwarn.

Replies are listed 'Best First'.
Re^2: warnings and strict -- The 2 Best Ways You Can Improve Your Programming
by jacques (Priest) on Oct 04, 2005 at 22:56 UTC
    Many people still use -w and for good reason. Some people like turning on warnings globally. Yes, it can be a good thing if you want that behavior. I am tired of people bashing it.

    Many big corporations with home-grown Perl modules still use the -w flag and wouldn't want it any other way.

      Many people still use -w and for good reason. Some people like turning on warnings globally. Yes, it can be a good thing if you want that behavior. I am tired of people bashing it.

      Well then I doubt you'll like to hear this: It doesnt actually work as you say it works. -w doesn't turn on warnings everywhere. It turns on warnings everywhere UNLESS a module or code uses lexical warnings. So if the module has "no warnings" then thats what happens.

      Maybe you meant -W?

      ---
      $world=~s/war/peace/g

      I agree that -w is still useful if that's what you really want and you are willing to accept the consequences. However, I've seen that in many, many cases, it is used out of ancient habit even when it's not the most appropriate. Using it together with warnings shows some of this confusion: if you want global warnings you just need -w, and if you want lexical warnings you just need warnings. If you use both, it's because you don't know what you want, or you don't understand the difference.

      (Note, here "you" is used as a generic pronoun, not refering to any specific person).

Re^2: warnings and strict -- The 2 Best Ways You Can Improve Your Programming
by liverpole (Monsignor) on Oct 04, 2005 at 19:12 UTC
    Thanks for pointing that out, itub.  I admit that I still use -w out of my original force of habit, and have yet to include a module which complains because of it.  Certainly, I would prefer to be required to turn warnings off globally if I knew I had to, rather than the opposite.  But I can see where, as my usage of modules increases, I may need to occasionally give up my predilection for the global -w.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-25 21:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found