Galen has asked for the wisdom of the Perl Monks concerning the following question:
This method reads and returns the next available lines of data from the object. You can use input_record_separator() to change the notion of what separates a line. The default is "\n".@lines = $obj->getlines([Timeout => $secs,]);
If a line isn't immediately available, this method blocks waiting for one or more lines, or time-out. You can override the object's timeout for this method using $secs. Also see timeout().
On eof a null array is returned. On time-out or other errors, the error mode action is performed.
A null array is returned for both eof and time-out when errmode is not set to "die". Use eof() and timed_out() to distinguish.
And:
timed_out - time-out indicator $boolean = $obj->timed_out; $prev = $obj->timed_out($boolean); This method indicates if a previous read or write method timed-out. With no argument this method returns true if a previous method timed-out. With an argument it sets the indicator. Normally, only internal methods set this indicator.
So how do I make use of this? I want to exit the following loop when timed_out is true, so that I can execute another command.
while (@rlines = $connect->getlines(Timeout =>1)) { print @rlines; }
Timed_out is a boolean value right? According to the info above, I figured I should just be able to say:
while (@rlines = $connect->getlines(Timeout =>1)) { if ($pop->timed_out) { print "Do something else\n"; exit; } print @rlines;
But this isn't working for me. The value of $pop->timed_out is null.
Edit 2001-03-22 by tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: timed_out usage?
by clintp (Curate) on Mar 22, 2001 at 22:44 UTC | |
by tye (Sage) on Mar 22, 2001 at 22:51 UTC | |
by Galen (Beadle) on Mar 22, 2001 at 23:57 UTC | |
by Galen (Beadle) on Mar 23, 2001 at 00:23 UTC | |
|
Re: timed_out usage?
by Galen (Beadle) on Mar 22, 2001 at 22:13 UTC |