Re^3: $_ not set in while <>by LanX (Sage)
|on Jun 06, 2021 at 12:46 UTC||Need Help??|
You seem to believe that the OP wants to read manual input from STDIN², but - as kcott noted - the OP said files.
Please note that an empty diamond <> defaults to <ARGV> .
So if you want to read from STDIN, better say so explicitly by writing <STDIN> .
Input from <> comes either from standard input, or from each file listed on the command line. Here's how it works: the first time <> is evaluated, the @ARGV array is checked, and if it is empty, $ARGV is set to "-", which when opened gives you standard input. The @ARGV array is then processed as a list of filenames. The loopis equivalent to the following Perl-like pseudo code:
NB: took me a while to find this, IMHO this should be at least mentioned/referenced in @ARGV
°) IIRC "-" is just an alias for STDIN which can be passed literally as argument at the command line
²) STDIN is not necessarily the keyboard, it depends how the program was started