The reason is that <> can be dangerous. From Perl documentation:
Since the null filehandle uses the two argument form of "open" in
perlfunc it interprets special characters, so if you have a script like
this:
while (<>) {
print;
}
and call it with "perl dangerous.pl 'rm -rfv *|'", it actually opens a
pipe, executes the "rm" command and reads "rm"'s output from that pipe.
If you want all items in @ARGV to be interpreted as file names, you can
use the module "ARGV::readonly" from CPAN, or use the double diamond
bracket:
while (<<>>) {
print;
}
Using double angle brackets inside of a while causes the open to use
the three argument form (with the second argument being "<"), so all
arguments in "ARGV" are treated as literal filenames (including "-").
(Note that for convenience, if you use "<<>>" and if @ARGV is empty, it
will still read from the standard input.)
my $last_fn = '';
my ($modules, $variables, $generated, $copy, $chainload, $continuation) = ([], {}, [], []);
my $skip_reading = defined($on_opt) || defined($off_opt);
-while (!$skip_reading && ($_ = <>)) {
+while (!$skip_reading && ($_ = <<>>)) {
if ($ARGV ne $last_fn) { # New script
die "Missing EOF in $last_fn" if $file;
die "Unfinished line in $last_fn" if $continuation;