From SELECT_TUT:
"... is used to efficiently monitor multiple file descriptors, to see if any of them is, or becomes, "ready"; that is, to see whether I/O becomes possible, or an "exceptional condition" has occurred on any of the descriptors. ...
So what is the point of select()? Can't I just read and write to my descriptors whenever I want? The point of select() is that it watches multiple descriptors at the same time and properly puts the process to sleep if there is no activity. Unix programmers often find themselves in a position where they have to handle I/O from more than one file descriptor where the data flow may be intermittent. If you were to merely create a sequence of read(2) and write(2) calls, you would find that one of your calls may block waiting for data from/to a file descriptor, while another file descriptor is unused though ready for I/O. select() efficiently copes with this situation."
Could someone explain me, what this means and how this works, maybe with a little example.
For example here is selected only one file-handle, why would I need a monitoring?
my $timeout = 10;
my ( $in, $out ) = ( '', '' );
vec( $in, fileno( STDIN ), 1 ) = 1;
select( $out = $in, undef, undef, $timeout );