Don't ask to ask, just ask | |
PerlMonks |
How to Test For Empty Piped Inputby roho (Bishop) |
on Sep 02, 2024 at 04:39 UTC ( [id://11161507]=perlquestion: print w/replies, xml ) | Need Help?? |
roho has asked for the wisdom of the Perl Monks concerning the following question:
I have a test program as shown below. When I pipe data to it, the output displays as expected. When I run the program stand-alone, it silently waits for input. I need a way to test for this condition and exit the program, but so far I can find none. Does anyone know a way of testing for this condition?
Here is the program which I named test.pl:
Note: I'm running on Windows, hence the use of "echo" below to pipe data. Test #1: echo a | test.pl (This works as expected) Test #2: test.pl (This silently waits for input. I need to test for this condition and exit the program)
"It's not how hard you work, it's how much you get done."
Back to
Seekers of Perl Wisdom
|
|