use Scalar::Util qw(looks_like_number); print looks_like_number($str) ? "numeric" : "not numeric\n";