Hello Monks,
I have a question I have been kicking around for a few days, and I'm baffled. Here is my problem, I will try to explain the problem as indepth as I possible can. First off, I am reading data from a constant data stream, and therefore I need to parse the data as it codes through, byte by byte. The data comes in, in a form such as this:
14|XXX\XXX|1.2541|1.2546|0|2001-07-17 10:25:22.17 0x00 16|XXX\XXX|1.2
+547|1.2552|0|2001-07-17 10:26:23.23 0x00
and on and on. The
0x00 is there to mean that each "string" is seperated by hex 00. What I am trying to do is read all the data from each "string" into one variable and stop reading when
0x00 is reached. Now, for some reason, I am having a heck of a time getting it to work. Here is my code (please note that this is only a portion, obviously):
do {
$socket->recv($response, 1);
$data = $data . $response;
} until ($response == hex(0x00));
print "$data\n";
close($socket) || die "Error terminating socket connection...\n";
Now, basically what happens is when reading if the code hits either 0 | , . - , it interprets this as hex 0x00 and terminates. Any insights?
Thanks,
Apterigo
Edit ar0n 2001-07-18
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.