use Regexp::Common qw/number/; sub make_num { return $_[0] =~ /(^$RE{num}{real}$)/ ? $1 : undef; }