package Foo { sub bar { warnings::warnif(deprecated => 'Foo:bar is deprecated'); } } use warnings; # no warnings 'deprecated'; # <-- uncomment this to disable the warning Foo::bar(); # <-- this is line 9