http://qs321.pair.com?node_id=147367

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

Greetings to all monks.

Please help me with this dilemma if you can. I am reading in a data stream through a socket and would like to read in the data stream beginning with "FOO" and ending with "END". I can read this in one line at a time, which works out perfectly for me, but I cannot get the reading in through this socket to stop when this hits END. What is happening is that I can see it reading in END, but the socket never closes and the listener continues to listen for more data through the socket. If you have any wisdom in this area I would appreciate your help.

Here is the data file.
"FOO" "localhost" "pd2x" "GOO" "Internal" "External" "Abbreviated" 00 50000 0 "ICK" "REQUEST" 0 "Yes" "No" "Absolutely" "END"
And here is the code I am using to read it in.
#!/usr/bin/perl -w # server use strict 'refs'; use strict 'subs'; use diagnostics; use strict; use sigtrap; use IO::Select; use IO::Socket::INET; $| = 1; ### Enable Autoflushing of I/O. my $sock = new IO::Socket::INET ( LocalAddr => localhost, LocalPort => 1000, Proto => 'tcp', Listen => 5, Reuse => 1, ); die "Could not create socket\n" unless $sock; my $buf = ' '; my $buffer = ' '; my $new_sock; while ($new_sock = $sock->accept()) { while (defined ($buf = <$new_sock>)) { if ($buf eq "\"END\"") { close ($sock); } else { print $buf; $buffer .= $buf; } } } print "$buffer \n";

peace, LOVE and ((code))

basicdez