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:

#!/home/mh/perl512/bin/perl use Net::SNMP; # end of script1, 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 -X use Net::SNMP; # end of script2, no 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 BEGIN { $^W = 0 }; use Net::SNMP; # end of script3, warnings
but surprisingly it doesn't - this emits warnings. Why is that?

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!