The best solution I found so far is this
$SIG{__WARN__} = sub {
my $w = shift;
warn $w unless $w =~ /::[ab]" used only once:/;
};
EDIT: An even better one, preserving an already existing signal handler. It still does not guarantee ours won't be overwritten.
my $orig_warn = $SIG{__WARN__};
$SIG{__WARN__} = $orig_warn
? sub { my $w = shift; $orig_warn->($w) if $w !~ /::[ab]" used onl
+y once/ }
: sub { my $w = shift; warn $w if $w !~ /::[ab]" used only once/ }
+;
EDIT: an even shorter one:
my $abwarn = $SIG{__WARN__} // sub { warn shift };
$SIG{__WARN__} = sub {
my $w = shift;
$abwarn->($w) if $w !~ /::[ab]" used only once:/;
};