#!/usr/bin/perl use warnings; use strict; use IO::Select; # remember what select says about mixing # buffered reading and "select", so even though the # code works, you might want to substitute # the read via <$fh> with: # my $input; # sysread( $fh, $input, 1024); # loop every 5 second my $timeout = 5; my $s = IO::Select->new(); $s->add( \*STDIN ); while (1) { if ( my @ready = $s->can_read($timeout) ) { # we got input for my $fh (@ready) { print "$fh\n"; my $input = <$fh>; print "got: $input"; } } else { # no input } # just to show that we're looping print scalar localtime,"\n"; }