Fellows

I was playing with pack() together with Compress::Zlib some time ago, so I could gen some compressed eval()-uable perl code for a programming toy.

While I think about the problem, I figured out that I need to represent the databytes generated from Compress::Zlib as a hexadecimal sequence of digits. I figured how to do this, but can't get the results back. Reading the manual, I wasn't able to determine what I'm doing The Wrong Way(tm). Below follows my code:

use Compress::Zlib; $code = q#print "Here I will put some nice code to be uncompressed and + eval()ed latter";#; $code = unpack 'H*', Compress::Zlib::memGzip( $code ); print pack 'H*', Compress::Zlib::memGunzip( $code ); # Here I get something very strange...

I'm almost sure that I'm doing something very stupid, but I can't see this now. Can anybody please point me a easy way to code this?

As a side-question, I would like to know your opinion about this: is this technique a good way to reduce the communications bandwidth needed to send Large Programs(tm) trought a highly used, low bandwidth serial communications channel between two machines? What you would do in my place?

Please note that this is just a sketch of an initial approach, not a complete solution for the problem.

May the gods bless you.

UPDATE: No, this is not homework! It's just a toy for my low cost service serial point-to-point home-made network laboratory.


"In few words, translating PerlMonks documentation and best articles to other languages is like building a bridge to join other Perl communities into PerlMonks family. This makes the family bigger, the knowledge greather, the parties better and the life easier." -- monsieur_champs


In reply to reversible pack()? by monsieur_champs

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.