http://www.perlmonks.org?node_id=505565

Using -w to enable warnings is a pretty-darn-good practice when doing development in Perl. But sometimes it's necessary to turn warnings off temporarily to avoid expected warnings while doing something low-level. You do this by clearing the special variable $^W. The operative word is "temporarily". Turning off warnings without turning them back on is a pretty-darn-bad practice.

Hence a useful pair of tests to include when you're testing code that involves third-party software (i.e., stuff Not Under Your Control):

is( $^W, 1, 'warnings are on' ); third_party_code(); is( $^W, 1, 'warnings are still on' );

This test pair might save you hours of headscratching.

In some cases, the third party software you're testing might itself be blameless, falling prey to problems in its dependencies. For example, Test::MockClass uses Hook::WrapSub, which sets $^W = 0; and, for reasons I'm unable to fathom, leaves it there. (Bug report submitted.)