Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I came across a few things with regard to the suppression of warnings that surprised me, so I thought I look for some enlightenment here...
I am using Perl 5.12 and Net::SNMP 6.0.0.
The following script produces 26 deprecation warnings:
Because the warnings come from another file you cannot simply disable them with "no warnings 'deprecated'", so if you want to get rid of them you can of course disable them globally with -X:#!/home/mh/perl512/bin/perl use Net::SNMP; # end of script1, warnings
Now I thought that you could achieve the same effect with $^W, so I had expected that this would also get rid of the warnings:#!/home/mh/perl512/bin/perl -X use Net::SNMP; # end of script2, no warnings
but surprisingly it doesn't - this emits warnings. Why is that?#!/home/mh/perl512/bin/perl BEGIN { $^W = 0 }; use Net::SNMP; # end of script3, warnings
Also I had expected that if you would run "perl script2" (the script with the -X in the shebang-line) you would see the warnings again (as there is now no -X on the commandline) but surprisingly you don't. It seems the -X of the shebang-line takes effect even though you explicitly invoke perl on the command line. Is that so?
Finally I would be interested if there is a way to globally disable specifically the deprecation warnings only.
Many thanks!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Supressing warnings
by toolic (Bishop) on Jul 22, 2010 at 15:08 UTC | |
Re: Supressing warnings
by kennethk (Abbot) on Jul 22, 2010 at 14:50 UTC | |
by morgon (Priest) on Jul 22, 2010 at 21:22 UTC | |
by almut (Canon) on Jul 22, 2010 at 21:39 UTC | |
by morgon (Priest) on Jul 22, 2010 at 23:27 UTC | |
by almut (Canon) on Jul 23, 2010 at 00:14 UTC | |
by morgon (Priest) on Jul 22, 2010 at 23:41 UTC | |
by Boldra (Deacon) on Jul 23, 2010 at 07:10 UTC | |
Re: Supressing warnings
by morgon (Priest) on Jul 22, 2010 at 13:53 UTC |
Back to
Seekers of Perl Wisdom