in reply to Input to array from STDIN, then print, but print is not working

You have good answers that address your immediate problems. However it looks like you are starting out on your Perl journy. May I suggest that you spend a little time perusing the Tutorials section here and especially Getting Started with Perl, Getting Deeper Into Perl and Pattern Matching, Regular Expressions, and Parsing (which is one of the reasons for choosing Perl after all).

Although I've never programmed Lisp, @arr1 = (@arr1,$_); has a Lispish flavour to it. In Perl it is more conventional to use push (as shown in some of the other answers) to add elements to the end of an array, or unshift to add elements to the start of an array. In similar fashion pop and shift are used to remove the element from the end and start of an array respectively.

Other list processing functions that are well worth being aware of are join, map and grep. For example the print loop could be rewritten using join as:

print join "\n", @arr1, '';

Note, the , '' on the end ensures a newline is emitted following the last array element.


DWIM is Perl's answer to Gödel