Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Disable Perl warning

by frozenwithjoy (Curate)
on Nov 26, 2012 at 06:31 UTC ( #1005575=note: print w/ replies, xml ) Need Help??

in reply to Disable Perl warning

Probably not the best way, but you could check which server you are on and then do:

unless ($main_server) { use warnings; }

Edit: As pointed out below, definitely not the way to do it!

Comment on Re: Disable Perl warning
Download Code
Replies are listed 'Best First'.
Re^2: Disable Perl warning
by davido (Archbishop) on Nov 26, 2012 at 06:51 UTC

    The warnings pragma is lexical, and somehow it seems inelegant to wrap an entire file's code in an unless statement. Probably a cleaner approach would be the if pragma:

    use if ! $MODE eq 'PRODUCTION', warnings;

    Personally I think I would prefer figuring out why there are warnings being generated in the first place, fix those that need fixing, and for the rest...

    { no warnings 'warning type'; # Code that generated the useless warning here }

    ...but I do understand that there are times when enough thought has been put into it, nobody who understands the warning would see them anyway, and ultimately it's just time to silence them all and move on.


Re^2: Disable Perl warning
by zwon (Monsignor) on Nov 26, 2012 at 06:44 UTC
    Note that use warnings is limited to the lexical block it it present in:
    if (1) { use warnings; } # no warnings say "Yup" if "zero" == 0;

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2015-10-04 21:54 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (105 votes), past polls