in reply to convert several two digit hex characters to ascii

Here's some code that gets you close to what you want. It'll get you started...
use strict; use warnings; while (<DATA>) { if (/0x([[:xdigit:]]+)/) { my $hexstr = $1; my $word; while ($hexstr =~ /(..)/g) {$word .= chr hex $1} s/0x$hexstr/$word/; } print; } __DATA__ blah0x4445434C41524520405420blah blah foo zoo 75858

prints out:

blahDECLARE @T lah blah foo zoo 75858

You'll need to figure out how to deal with the 2nd "blah", whose 1st letter is a valid hex digit.

Replies are listed 'Best First'.
Re^2: convert several two digit hex characters to ascii
by ikegami (Patriarch) on Dec 01, 2008 at 22:33 UTC

    You'll need to figure out how to deal with the 2nd "blah", whose 1st letter is a valid hex digit.

    He already has. He specified the nibbles are to be taken "two at a time".

    He still has the problem of distinguishing "foo(0x1234)bar" from "foo(0x1234ba)r", though.

    By the way, I think your code handles "blah 0x4142 blah 0x4142 blah" oddly, but I'm pleased with its handling of "x0x0x kisses and hugs x0x0x".