http://qs321.pair.com?node_id=948517


in reply to use of "use X"

BEGIN { my $debug = 0; unless ($debug) { $INC {"warnings.pm"} = 1; no strict 'refs'; *{"warnings::import"} = sub {1;}; } } use warnings;
Of course, that will prohibit warnings to be turned on from anywhere in your program.

If you can live with just one category enabled if debugging is off, you could do:

BEGIN { $::DEBUG = 1; } use warnings $::DEBUG ? "all" : "io"; # Or some other category.