in reply to IO::Select question

The code that you posted is not actually using the IO::Select module, but instead the built-in select call.

To answer your question about what the code does, the vec() call sets up a value where the bits indicate which filehandles should be watched for input or output. In essance, this vec() setup will turn on the bit in position fileno(STDIN) in $rin. Since STDIN is usually 0, $rin will be 1 after this call. If you then add a call that sets the bit for STDOUT (usually fileno 1) in addition to STDIN, $rin would be 3. This setup wouldn't make a lot of sense in the select call since you can't read from STDOUT.

Once $rin and $win have been set up to watch the appropriate handles the vectors are combined to be used to detect handles with eexceptions.

The select() call then:

$timeout indicates how long the handles should be watched. If a handle state changes before $timeout expires, select returns. When select() returns, the number of handles that have data, can block and have exceptions are returned, along with the time that remained on the timeout (Windows versions of Perl return the timeout that was passed in). Due to the assignments in the call, $rout will contain the vector that indicates the filehandles that have data available, $wout will be a vector that indicates which handles would block, and $eout is a vector that indicates the handles that have exceptions. Using this method prevents you from having to re-set the vectors if you wanted to call select again. IO::Select puts a prettier face on the calls so that you don't have to do the vec() calls yourself.

If you have access to a UNIX box, it may be helpful to look at the select() man page.