[KLUG Programming] perl
Dirk H Bartley
programming@kalamazoolinux.org
02 Sep 2003 10:58:11 -0400
Hello There
Here is a chunk of code I need to replace. It takes data from a read
file-handle from a network socket and send it to a temporary file. It
works just fine with one problem. Some of the text that gets sent is
without the newline causing this chunk of code to wait for the newline
as opposed to sending it to the temporary file. What I need is to
accomplish this on a character basis as opposed to a line basis. Does
anyone have any ideas of how I can accomplish this?
open2($rdrfh, $wtrfh, "netcat tristar 7011" );
...
open( TOHOLD, ">".$holdfile );
# the if{} block runs only in the parent process
if ($kidpid) {
# copy the socket rdrfh to a hold file
while (defined ($lineout = <$rdrfh>)) {
$|=1; #autoflush
open( TOHOLD, ">>".$holdfile );
print TOHOLD $lineout;
close( TOHOLD );
}
# gets here when ser2net is killed
}