Let me quote from the Camel,
second edition, dating from 1996, shortly after the release of perl 5.003. On page 54, while discussing the angle operator:
Here's how it works: the first time <> is evaluated, the @ARGV array is checked, and if it is null, $ARGV[0] is set to "-", which when opened gives you standard input. The @ARGV array is then processed as a list of filenames. The loop:
while (<>) {
... # code for each line
}
is equivalent to the following Perl-like pseudocode:
@ARGV = ('-') unless @ARGV;
while ($ARGV = shift) {
open(ARGV, $ARGV) or warn "Can't open $ARGV: $!\n";
while (<ARGV>) {
... # code for each line
}
}
except that it isn't so cumbersome to say, and will actually work. It really does shift @ARGV and put the current filename into variable $ARGV. It also uses filehandle ARGV internally -- <> is just a synonym for <ARGV>, which is magical. (The pseudocode doesn't work because it treats <ARGV> as non-magical.)
If you then switch to pages 191-194, it discusses the open function, including the effects of leading and trailing pipes in the filenames.