in reply to Replacement regular expression which return the number of replacement it does
See the perlretut tutorial on regular expressions and search for this (which specifically deals with s///)