You need to escape the backslash character: s/\\x(\d+)/'&#' . hex($1) . ';'/ge works for me.
Oddly, you have doubled it in the loop you posted, but not in the original regexp
In reply to Re: Control Characters (\xNN) in HTML
by tommyw
in thread Control Characters (\xNN) in HTML
by garliqua
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |