Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: use of -w and warnings

by davido (Cardinal)
on Dec 10, 2003 at 16:31 UTC ( #313767=note: print w/replies, xml ) Need Help??


in reply to use of -w and warnings

The section from perllexwarn that you might find most interesting comes under the headline, "What's wrong with -w and $^W":

Although very useful, the big problem with using -w on the command line to enable warnings is that it is all or nothing. Take the typical scenario when you are writing a Perl program. Parts of the code you will write yourself, but it's very likely that you will make use of pre-written Perl modules. If you use the -w flag in this case, you end up enabling warnings in pieces of code that you haven't written.

The section then goes on to describe how $^W falls short of providing lexical scoping for -w.

For simple code snippets, -w and use warnings are synonymous. But for more elaborate code, and scripts that use modules, or scripts that need lexical control over warnings, the pragma is preferable over the command-line switch.


Dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2021-03-05 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (109 votes). Check out past polls.

    Notices?