in reply to Re^2: Hex-matching Regex pattern in scalar
in thread Hex-matching Regex pattern in scalar

I entirely agree with Corion in that it seems to be a problem with encoding. It would be ideal to fix this at source (the IBM tool). If that isn't possible then Corion's approach sounds like the next best plan.

However, since you said:

So, another way to describe my problem is that I have not been able to write a subroutine that accepts a string, a 'from' hex value and a 'to' hex value and returns a modified string.

let me supply this alternative which shows such a subroutine:

#!/usr/bin/env perl use strict; use warnings; use Test::More; my $instr = "a\xe9b\xe9"; my $outstr = replace ($instr, "\xe9", "\x65"); is ($outstr, 'aebe'); done_testing; sub replace { my ($in, $find, $replace) = @_; $in =~ s/$find/$replace/g; return $in; }

Replies are listed 'Best First'.
Re^4: Hex-matching Regex pattern in scalar
by CliffG (Novice) on May 20, 2016 at 13:34 UTC
    Thanks to all for your help, and the different approach was what I needed. I can't change IBM's product so I took a slightly different angle and simply replaced encoding="UTF-8" with encoding="Latin1" and that allowed LibXML to parse the doc correctly.

    Job done :o)