$value = undef; $value = (0 + "$1$3") if $thing =~ m/ ^ (\-|\+)? # optional sign: $1 (\$)? # optional dollar sign: $2 ( \d+ # at least one digit (,\d\d\d)* # zero or more comma groups (\.\d*)? # optional fractional part | (\.\d+) # only a fractional part ) # the whole mantissa: $3 $ /x; print "numeric! value = $value\n" if defined $value;