I need to detect if input has been to my script or not.
For example, I would like to differentiate between an invocation from
the two lists below:
Examples where input is "provided":
perl myscript.pl input.txt
perl myscript.pl < input.txt
executable_that_writes_to_sdtout | perl myscript.pl
Example of where no input is "provided":
perl myscript.pl
---
I've tried:
if (seek(STDIN,0,1)) {
#input provided
}
else {
# no input provided
}
which appears to work if an input file was specified or redirection
was done but does not work for piped data.
If (eof(STDIN)) {
}
which blocks if no input was provided.
I'm using Windows XP.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/