Try to use
select with a small timeout value.
Maybe you can use also the perl implementation of
ioctl that allow you to do non-blocking i/o ( among many other things )
Update :
It's also possible to handle the "IO" signal by linking some function to $SIG{IO} sighandler, and play with the filehandle's flags with
fcntl
No more details : searching is the way of understanding...
Hope this help :)