in reply to <input> for array

<> 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.