.. And the other problem is that 'can_read()' waits indefinitely for data. If you want it to wait 30 seconds and then give up, you need to call it: can_read(30)
At the moment you're only comparing the time if data actually comes through - if its only doing that when you press the keyboard, I assume you've added 'STDIN' to the sockets in the IO::Select object.
C.