http://qs1969.pair.com?node_id=97866

Apterigo has asked for the wisdom of the Perl Monks concerning the following question:

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