Don't ask to ask, just ask | |
PerlMonks |
Re: Using stdin only if there is input on it, but skipping it if there is no databy salva (Canon) |
on Nov 18, 2020 at 08:39 UTC ( [id://11123774]=note: print w/replies, xml ) | Need Help?? |
You can use select (see perlfunc) to check whether data is available from a file descriptor.
Though, that could incur in a race condition, for instance, when the data is generated by another process running in parallel. So, you should probably set a safe waiting time (the last select argument).
In Section
Seekers of Perl Wisdom
|
|