in reply to Regex substitute with both a sub and other data
When you use /e then the stuff in the second part of s/// needs to be valid Perl code. $1md5sum($2)$3 is not valid Perl code; you need to add some concatenation operators (.) in there...
$xml =~ s/(\<tag\>)(\d{11})(\<\/tag\>)/$1.md5_hex($2).$3/eg;
Or, prettier:
$xml =~ s{ (<tag>) (\d{11}) (</tag>) }{ $1 . md5_hex($2) . $3 }xeg;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex substitute with both a sub and other data
by AnomalousMonk (Archbishop) on Aug 23, 2013 at 12:21 UTC |