in reply to Original Enough?

this is real cool. the thing i don't understand is, why $_=<> is reading the first line, not from STDIN. could you please give me a hint about this? thanks alot.

Replies are listed 'Best First'.
Re^2: Original Enough?
by perldeveloper (Scribe) on Jul 10, 2004 at 11:08 UTC
    The diamond operator <> attempts to read from the file denoted by the elements in @ARGV (it tries reading from $ARGV[0] and increases the index in case opening the file denoted by the previous index fails).

    An assignment of the form @ARGV=$0 is the same as @ARGV=($0), which actually means $ARGV[0]=$0. Since $0 is the filepath of the perl script itself, the diamond operator will read the first line from the perl script file.

    The diamond operator will read from STDIN only if the @ARGV list is empty.