use Data::Dumper; $str = $ARGV[0]; $a = $str + 0.0; if ($a =~ m/INF/) { use bignum; $a = $str + 0.0; no bignum; } print Dumper($a);