in reply to How to capture the "isn't numeric" warning?
A solution with Try::Tiny:
#!/usr/bin/env perl use strict; use warnings; use Try::Tiny; my $X = "abc"; try { use warnings FATAL => 'numeric'; $X = int($X); } catch { $X = "This should have been a number"; }; print $X;
|
|---|