Input, Output, and Lists
We'll finish up today's lesson as we did yesterday: by talking a little more about input and output, this time with list and array context in mind. There are two topics to cover here that will help you work more with input and with files:
Using <STDIN> in a list context
Printing lists
Using <STDIN> in list context
Yesterday, you learned about <STDIN>, and how it's used to read data from the standard input. Up to now, we've been using it like this:
chomp($in = <STDIN>);
A close look at that line shows that you're using <STDIN> here in a scalar context—you're assigning it to the scalar variable $in. Like many other Perl operations, the input operator <> behaves differently in a list context than it does in a scalar one. ...
Get Sams Teach Yourself Perl in 21 Days, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.