On Aug 13, Jeremy Kister said:
>I'm stumped on how to read from a filehandle, where I don't know how many
>lines are waiting for me.
You probably want to use IO::Select.
>Is there a way to tell if i have data in <$sock> waiting for me, without
>actually reading from the file handle (which could cause it to wait for
>input) ?
use IO::Select;
my $s = IO::Select->new;
$s->add(\*SMTP_HANDLE);
# 0 = timeout (return immediately if nothing waiting)
while (my ($pending) = $s->can_read(0)) {
print scalar <$pending>;
}
I *think* that's what you want.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ % -- Meister Eckhart
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>