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;
In reply to Re: Regex substitute with both a sub and other data
by tobyink
in thread Regex substitute with both a sub and other data
by FloydATC
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |