Wise monks, I ask your help for my unpack/pack ignorance. I need to present data in the same format as a Windows registry file (.reg, ascii not unicode)
Using the perl debugger, the hex data read from the registry looks like this:
DB<2> x $value 0 "\cA\cB\cC\cD\cE\cF\cG\cH\cI\cJ\cK\cL\cM\cN\cO\cZ\cP\cQ\cR\cS\cT\cU +\cV\cW\cX\cY\cZ\e\c\\c]\c^\c_ !\"#\$%&'()*+,-./0123456789:;<=>?\@ABCD +EFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
and after doing ( $value ) = unpack("H*", $value); it looks like this:
DB<3> x $value 0 '0102030405060708090a0b0c0d0e0f1a101112131415161718191a1b1c1d1e1f20 +2122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f4041424 +34445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f'

What I need is comma-separated two-digit numbers, like this:

01,02,03,04,05,06,07,08,09,0a,0b,0c,0d,0e,0f,1a,10,11,12,13,14,15,16,1 +7,18,19,1a,1b,1c,1d,1e,1f,20,21,22,23,24,25,26,27,28,29,2a,2b,2c,2d,2 +e,2f,30,31,32,33,34,35,36,37,38,39,3a,3b,3c,3d,3e,3f,40,41,42,43,44,4 +5,46,47,48,49,4a,4b,4c,4d,4e,4f,50,51,52,53,54,55,56,57,58,59,5a,5b,5 +c,5d,5e,5f
And I also need to be able to go in the opposite direction, from the comma-delimited numbers to hex data. How is this done? I'd really appreciate a code fragment rather than pointers to docs, as my mind seems unable to grasp this particular issue at present! Grateful thanks in hope.

In reply to unpack and pack by anadem

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.