[Israel.pm] simple script question.

Mikhael Goikhman migo at homemail.com
Sun Sep 26 07:10:34 PDT 2004


On 26 Sep 2004 13:58:58 +0200, Offer Kaye wrote:
> 
> Note that I:
> 1. Changed "<STDIN>" to "<>"  - they are the same.

This is not quite correct. "<>" is "<ARGV>", not "<STDIN>".
There are several serious differences.

1) "<>" only reads from standard input if there are no file arguments
supplied to the script. i.e. my-script file1.txt file2.txt, otherwise
it opens supplied files sequentially.

2) This causes all kinds of quirks regarding beggining and end of file,
because "<>" may actually read from several files and their content is
not exactly concatenated and divided by "\n". For example, usually you
may safely assume that all lines except for the last one end with "\n".
This is true for "<STDIN>", but not for "<>"!

P.S. Guess what this command does: perl -pe '' . . . - - - . . .
(No, it does not print the word "SOS" 100 times.)

Regards,
Mikhael.

-- 
perl -e 'print+chr(64+hex)for+split//,d9b815c07f9b8d1e'



More information about the Perl mailing list