IMHO what you suggested can be achieved by
use warnings;
no warnings "uninitialized";
but actually this gave me an idea to use __WARN__ and caller() to check if the warning happened on a line with a debug call and hide those.
use 5.010;
use strict;
use warnings;
my $x = 42;
my $y;
$SIG{__WARN__} = sub {
my $warn = shift;
my ($package, $filename, $line) = caller;
if (open my $fh, '<', $filename) {
my @lines = <$fh>;
return if $lines[$line-1] =~ /debug\(/;
}
print $warn;
};
my $z = $x+$y;
debug("x=$x y=$y");
sub debug {
say shift;
}
Though this will have a runtime impact we need to consider. Of course then we could cache the filename/rownumber pairs to reduce the cost.
Thank you for the suggestion.