in reply to How to modify a warning message within a sub?

Another solution is to make warnings fatal (see perllexwarn) and then handle it all with eval. Disadvantage is that it will also catch ordinary errors.

my $success = eval { use warnings FATAL => 'all'; risky_operation(); 1; }; unless ($success) { warn frob_message($!); }

Replies are listed 'Best First'.
Re^2: How to modify a warning message within a sub?
by Marshall (Canon) on Aug 09, 2011 at 05:19 UTC
    It's a good thought! But I think that the other solutions are a bit better.