The best answer which I can offer is ... It depends.

If you are referring to the transmission of Perl data structures such as arrays and hashes, you may find some worth in the Storable module which allows such data structures to be serialised into a 'flat' form for such transmission. Alternatives to this module include Data::Dumper and FreezeThaw.

If you are referring to a plain block of information, it may be worth looking at encapsulating such data into a discrete format which can be recognised at the other end of the socket and unpacked accordingly. A simple example of such a format would be uuencoding often used in mail transmission where the encoded data is transmitted between header BEGIN and trailer END lines of text.

 

perl -le 'print+unpack("N",pack("B32","00000000000000000000001000011010"))'


In reply to Re: Sending data structures via sockets by rob_au
in thread Sending data structures via sockets by sawanv

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.