Probably the easiest, and most portable (since, apparently,
Windows perl only supports
select for sockets, not to mention that it probably doesn't support termios.), way to do this would be to use
Term::ReadKey:
use Term::ReadKey;
for (;;) {
if (defined(my $c = ReadKey(-1))) {
# got a character $c, process
}
# do other stuff
}