Perl 5 version 6.0 documentation
- select FILEHANDLE
Returns the currently selected filehandle. Sets the current default filehandle for output, if FILEHANDLE is supplied. This has two effects: first, a
FILEHANDLE may be an expression whose value gives the name of the actual filehandle. Thus:
Some programmers may prefer to think of filehandles as objects with methods, preferring to write the last example as:
- use IO::Handle;
- select RBITS,WBITS,EBITS,TIMEOUT
If you want to select on many filehandles you might wish to write a subroutine:
The usual idiom is:
- ($nfound,$timeleft) =
- select($rout=$rin, $wout=$win, $eout=$ein, $timeout);
or to block until something becomes ready just do this
Most systems do not bother to return anything useful in $timeleft, so calling select() in scalar context just returns $nfound.
Any of the bit masks can also be undef. The timeout, if specified, is in seconds, which may be fractional. Note: not all implementations are capable of returning the$timeleft. If not, they always return $timeleft equal to the supplied $timeout.
You can effect a sleep of 250 milliseconds this way: