If the person running the program types three lines, then presses the
proper keys needed to indicate end-of-file, the array ends up with
three elements. Each element will be a string that ends in a newline,
corresponding to the three newline-terminated lines entered.
Wouldn't it be nice if, having read those lines, you could
chomp the newlines all at once?
It turns out that if you give chomp a list of lines, it will remove the
newlines from each item in the list. For example:
@lines = <STDIN>; # Read all the lines
chomp(@lines); # discard all the newline characters
But the more common way to write that is with code similar to what we
used earlier:
chomp(@lines = <STDIN>); # Read the lines, not the newlines
Although you're welcome to write your code either way in the
privacy of your own cubicle, most Perl programmers will expect the
second, more compact, notation.