in reply to Using <> in the presence of @ARGV
<STDIN> is fine, what becomes a problem is <>.
use strict; use warnings; while (<>) { print; }
If you run this with perl -w blah.pl something, <> is going to read from something, and fails if something is not a file etc. This is probably a feature you don't want.
In general, the best practice is to avoid the feature of reading from @ARGV, and in your code use <STDIN>. If you want to have a choice of reading either a file or user input, use redirect.
use strict; use warnings; while (<STDIN>) { print; }
If you want the input come from a file instead of user, just do something like perl -w blah.pl <somefile.
|
|---|