How do I temporarily block warnings?

If you are running Perl 5.6.0 or better, the use warnings pragma allows fine control of what warning are produced. See perllexwarn for more details.

    {
	no warnings;          # temporarily turn off warnings
	$a = $b + $c;         # I know these might be undef
    }
If you have an older version of Perl, the $^W variable (documented in perlvar) controls runtime warnings for a block:

    {
	local $^W = 0;        # temporarily turn off warnings
	$a = $b + $c;         # I know these might be undef
    }
Note that like all the punctuation variables, you cannot currently use my() on $^W, only local().
Back to perlfaq7