start page | rating of books | rating of authors | reviews | copyrights

Learning Perl on Win32 Systems

Learning Perl on Win32 SystemsSearch this book
Previous: 3.5 Scalar and List Context Chapter 3
Arrays and List Data
Next: 3.7 Variable Interpolation of Arrays
 

3.6 <STDIN> as an Array

One previously seen operation that returns a different value in a list context is <STDIN> . As described earlier, <STDIN> returns the next line of input in a scalar context. However, in a list context, it returns all of the remaining lines up to the end-of-file. Each line is returned as a separate element of the list. For example:

@a = <STDIN>; # read standard input in a list context

If the person running the program types three lines, then hits CTRL-Z (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.


Previous: 3.5 Scalar and List Context Learning Perl on Win32 Systems Next: 3.7 Variable Interpolation of Arrays
3.5 Scalar and List Context Book Index 3.7 Variable Interpolation of Arrays