note
kennethk
You can detect the presence of waiting input using [doc://select], like:
<c>use strict;
use warnings;
my $vector = '';
vec($vector,fileno(STDIN),1) = 1;
if (select($vector,undef,undef,0.01)) {
while (<>) {
print;
}
}</c>
<p>where I have set a 10 millisecond timeout. Might be easier and more portable though to simply pass the filename as argument, and [doc://open] it yourself. Like many other unix command line tools.
929359
929359