I once had to try something similar getting v3 data in a stream from a phone system, the following may help you organize the stream of values coming from the socket server, you can break out the stream into a hash of fieldnames->values using unpack() as in the following code.. to get your final values it looks like you have to do more, like reverse the string or do some more math on it, but at least you can organize the stream into a hash to work with it?
#!/usr/bin/perl -w use strict; my %fields; my @field_names = qw/FIELD1 FIELD2 FIELD3 FIELD4 FIELD5 FIELD6 +/; # $pack_definition derived from the format in the Packet Layout Guide, + e.g. # ignore T18 # FF15 1B 8 A028 3043 D2070000 my $pack_definition = 'a4 a2 a1 a4 a4 a8'; while ( <DATA> ) { @fields{@field_names} = unpack($pack_definition,$_); } #this is just to display what we got, in hex while (my($k,$v) = each %fields) { print sprintf("% 9s",$k) . ' => ' . hex($v) . $/; } __DATA__ FF151B8A0283043D2070000

Note how the FIELD2=27 as it says in packet layout guide. Maybe you already found a better way but if not, HTH

-Harold

In reply to Re: Parsing Data from a PHP Socket Server by hsinclai
in thread Parsing Data from a PHP Socket Server by lmrd_1

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.