in reply to Re: Regex substitute with both a sub and other datain thread Regex substitute with both a sub and other data
... or even prettier (but untested): $xml =~ s{ <tag> \K (\d{11}) (?= </tag>) }{ md5_hex($1) }xmseg;