aravind ramesh
aravind ramesh

Reputation: 307

does "STDIN" written in <> effect behaviour of perl program?

I've two perl scripts, both of them wait for user to enter some input as below,

Does both of them are same ? Does "STDIN" written in <> are just to for user-readability of code ? If not please tell me the differences.

a) $in = <STDIN>;

b) $in = <>;

Upvotes: 5

Views: 389

Answers (3)

Kotu
Kotu

Reputation: 1102

More information about <> you can get from perlop, section about I/O Operators

Upvotes: 0

user507077
user507077

Reputation:

The form <FILEHANDLE> will only read from FILEHANDLE.

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

Upvotes: 13

mob
mob

Reputation: 118695

<> is shorthand for <ARGV>. And ARGV is a special filehandle that either opens and iterates through all of the filenames specified in @ARGV (the command-line arguments) or gets aliased to STDIN (when @ARGV is empty).

Upvotes: 10

Related Questions