http://qs321.pair.com?node_id=1167099

fireblood has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I'm trying to use STDIN first to read from the output of the previous process and then to read from the terminal. According to http://perldoc.perl.org/perlop.html#I%2fO-Operators I should be able to do this:

"The <> symbol will return undef for end-of-file only once. If you call it again after this, it will assume you are processing another @ARGV list, and if you haven't set @ARGV , will read input from STDIN."

That's what I need! My simplified program, called pgm, is the following:

#!/opt/local/tools/bin/perl use 5.24.0; use strict; use warnings; my $response; unless (-t STDIN) { while (<STDIN>) { chomp; print "input line is $_\n"; } } print "Now enter something: "; $response = <>; print "You entered -->", $response, "<--\n";

and I invoke it as follows:

echo Hello | pgm

But it doesn't wait for anything to be entered at the <>:

echo Hello | pgm input line is Hello Use of uninitialized value $response in print at /userdata/cfor/utils/ +worklib/pgm line 25. Now enter something: You entered --><--

Wouldn't the while (<STDIN>) end because it encountered EOF, after which it should then read input from STDIN?