perl program behavior effect? I have two perl scripts, both of which are waiting for the user to enter some input, as ...">

Is "STDIN" written in the <> perl program behavior effect?

I have two perl scripts, both of which are waiting for the user to enter some input, as shown below,

Are both the same? Is "STDIN" used in <> just for readability? If not, please tell me about the differences.

 a) $in = <STDIN>; b) $in = <>; 
+4
source share
3 answers

The form <FILEHANDLE> will only reckon with FILEHANDLE .

The form <> will read from STDIN if @ARGV empty; or from all files whose names are still in @ARGV , which contains the command line arguments passed to the program.

+13
source

<> is short for <ARGV> . And ARGV is a special file descriptor that either opens or iterates through all the file names specified in @ARGV (command line arguments), or gets an alias for STDIN (when @ARGV empty).

+9
source

You can get more information about <> from perlop, a section on I / O statements

0
source

All Articles