Just remove any comma that precedes the number using the prediction :
s/,(?=\d)//
If you tried s/,\d/\d/ , Perl will consider the replacement as a double-quoted string. Since there is no escape code \d , the backslash is simply ignored and d used.
If you want to substitute a match with part of the match, you need to use captures (see ysth answer).
My above substitution does not include a digit in the matched string, so just substituting a comma for an empty string (i.e. deleting it), but still claims that the digit is followed by a comma.
amon
source share