Not to mention that the original almost 21 year old perl1 manpage version contains no such disclaimers about it being pseudo code.
The null filehandle <> is special and can be used to emulate the behav +- ior of sed and awk. Input from <> comes either from standard input, o +r from each file listed on the command line. Here's how it works: th +e first time <> is evaluated, the ARGV array is checked, and if it i +s null, $ARGV[0] is set to '-', which when opened gives you standar +d input. The ARGV array is then processed as a list of filenames. Th +e loop while (<>) { ... # code for each line } is equivalent to unshift(@ARGV, '-') if $#ARGV < $[; while ($ARGV = shift) { open(ARGV, $ARGV); while (<ARGV>) { ... # code for each line } } except that it isn't as cumbersome to say. It really does shift arra +y ARGV and put the current filename into variable ARGV. It also use +s filehandle ARGV internally. You can modify @ARGV before the first < +> as long as you leave the first filename at the beginning of the array +.
Not to mention that presuming as tye does above that that there was to be an implied < prepended to filenames doesn't make any sense because that would break the very explicitly documented behavior of an argument of '-' triggering the 'magic two-arg open of "-" opens STDIN' behavior (which, again, was explicitly meant to behave this way and has done so for 20+ years worth of perls.)
The cake is a lie.
The cake is a lie.
The cake is a lie.
In reply to Re^10: magic-diamond <> behavior -- WHAT?! (coy)
by Fletch
in thread magic-diamond <> behavior -- WHAT?!
by repellent
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |