in reply to
Update: I got that wrong. See the correct explanation from ikegami (below).
While the problem has been solved, it has not been explained. In the first line:
Reading <STDIN> in list context reads until the end of file for STDIN. At that point, you can no longer read from STDIN, so line 4 fails:
@piped = <STDIN>;
The solutions suggested either avoid using STDIN for user input (reading from the console) or close and re-open STDIN.
$user_input = <STDIN>;