in reply to unpack and pack

my $value = "\cA\cB\cC\cD\cE\cF\cG\cH\cI\cJ\cK\cL\cM\cN\cO\cZ\cP\cQ\cR +\cS\cT"; $value =~ s/(.)/sprintf "%02x,", ord($1)/sge; chop $value; print $value, "\n";
or to create a new string instead of modifying the existing one:
my $value = "\cA\cB\cC\cD\cE\cF\cG\cH\cI\cJ\cK\cL\cM\cN\cO\cZ\cP\cQ\cR +\cS\cT"; print join(',', map {sprintf "%02x", ord} split(//, $value)), "\n";

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: unpack and pack
by anadem (Scribe) on Apr 28, 2005 at 19:07 UTC
    thanks!

    the ASCII interpretation must be caused by my code preceding the unpack, as this solution also gives the same 30,31,30,32 string using data my app has read from the registry, though it (and most likely ikegami's and John's solutions too) shows the correct 01,02,03 string from $value="\cA\cB..."

    Obviously it's time i understood more of what I'm doing!