When I run the code below on a Linux system, as expected it outputs Nothing is ready about every two seconds, and also outputs anything entered on to console.
But on Windows, can_read returns instantly with zero items.
use IO::Select;
my $sel = IO::Select->new();
$sel->add(\*STDIN);
while ( 1 ) {
my @ready = $sel->can_read(2);
if ( scalar @ready == 0 ) {
print "Nothing is ready\n";
}
foreach my $fh ( @ready ) {
if ( $fh eq \*STDIN ) {
my $in = <STDIN>;
print "got $in from stdin\n";
}
}
}
It seems that select works only on Windows sockets and not on STDIN. How can I use IO::Select on STDIN on a Windows system?