$ cat 11144614.pl
#!/usr/bin/env perl
use warnings;
use strict;
my $hfile = 'foo.txt';
# GOOD
open(HFILE, '>', $hfile) or die "$hfile: $!";
print HFILE << "#EOT";
#Usage: foo.pl
#EOT
# BAD
open(my $HFILE, '>', $hfile) or die "$hfile: $!";
print $HFILE << "#EOT";
#Usage: foo.pl
#EOT
# GOOD
open($HFILE, '>', $hfile) or die "$hfile: $!";
print {$HFILE} << "#EOT";
#Usage: foo.pl
#EOT
$ perl 11144614.pl
Argument "#EOT" isn't numeric in left bitshift (<<) at 11144614.pl lin
+e 15.
10294240
$ perl -MO=Deparse,-p 11144614.pl
use warnings;
use strict;
(my $hfile = 'foo.txt');
(open(HFILE, '>', $hfile) or die("${hfile}: $!"));
print(HFILE "#Usage: foo.pl\n");
(open(my $HFILE, '>', $hfile) or die("${hfile}: $!"));
print(($HFILE << '#EOT'));
(open($HFILE, '>', $hfile) or die("${hfile}: $!"));
print({$HFILE;} "#Usage: foo.pl\n");
11144614.pl syntax OK
Indirect Object Syntax strikes again... and from print:
NOTE: If FILEHANDLE is a variable and the next token is a term, it may be misinterpreted as an operator unless you interpose a + or put parentheses around the arguments.
Update: -MO=Deparse,-p makes it even more obvious.