my $result; { my $flag; local $SIG{__WARN__} = sub { # catch error in @_, set $flag }; $result = int($x); something_different($x,$result) if $flag; }