sub fixRaw(\$) { my $raw = shift; return undef unless defined $raw and defined $$raw; ################################################################## # Split the raw into 2 byte chunks, interpret each chunk as hex, # then pack it! ################################################################## return join('',map(pack('C', hex($_)), $$raw =~ /../sg)); # The below also works... I don't know which is fastest. # return join('',map(pack('C', hex($_)), unpack("a2"x(length($$raw)/2),$$raw))); }