<> in list context (as it is in @_ = <STDIN>) reads until the end of the file (which ^Z signals).
But you have that in a loop, so it keeps reading to the end of the file over and over again until the while loop exits. That will happen when zero lines are returned by <STDIN>.
Please use <p> at the start of every paragraph and <c>...</c> around your code. You should know this by now.
| [reply] [d/l] [select] |
First, <code> tags are your friends - please read Writeup Formatting Tips.
This issue you are encountering is a question of scalar context for an array. Your first code tests $_ to see if it is false and exits the loop if it is. When you enter your control character, that evaluates to false and the while loop exits. You second code checks @_. Since this is an array, in scalar context (such as a conditional), it evaluates to the number of elements contained therein. Since it contains 1 element, it is true and thus the loop will not break. Read perldata for more details.
| [reply] [d/l] [select] |
<> behaves differently according to the context, in scalar context it fetches a single line, in list context it fetches lines until end of file(EOF).
Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.
| [reply] |
| [reply] |