To clarify holo's response, <> will read from STDIN only when all the files on the commandline have been exausted. In scripts without arguments, this will always read from STDIN. But since your script takes arguments, it won't DWIM (at least, not right away...)
| [reply] [d/l] |
$ echo "one" > file1; echo "two" > file2
$ echo "three" | perl -e 'print while <>' file1 file2
one
two
This script requires at least one argument to work so I assume that unless @ARGV is cleared, <> will never read from STDIN.
| [reply] [d/l] [select] |
According to perlop, we are both sorta right:
The first time <> is evaluated, the @ARGV array is checked, and if it is empty, $ARGV[0] is set to "-", which when opened gives you standard input. The @ARGV array is then processed as a list of filenames.
So if there is nothing in @ARGV to begin with, it will read from STDIN. But as it reads from @ARGV, it unshifts the files from the array. So when the loop ends, $#ARGV = 0. But...
The <> symbol will return undef for end-of-file only once. If you call it again after this, it will assume you are processing another @ARGV list, and if you haven't set @ARGV, will read input from STDIN.
So it will return false once and then begin to read from STDIN.
| [reply] [d/l] |