Subject: | HERE docs triggers spurious error and confuses reported line number |
HERE docs confuse the parser. A spurious severity 5 error is created
(Variable declared in a conditional statement... Declare variables
outside of the condition).
The line number is wrong. It's too high by 3+N, where N is the number
of lines in a single previous HERE doc. (I didn't try it with multiple
previous here docs, though I'd expect it to be dependant.)
PPI::Version 1.115
Perl::Critic::Version 0.17
perlcritic version 0.17
Perl v5.8.7 on cygwin
Subject: | perlcritic_heredoc_fix.pl |
#!/usr/bin/perl
use warnings;
use strict;
my $line_changing = " 1\n 2\n";
my $tr_format = "<tr>\n\t %s\n\t</tr>";
foreach my $var_name (qw(foo bar bas)) {
printf $tr_fmt, $var_name;
}
Subject: | perlcritic_heredoc_bug.pl |
#!/usr/bin/perl
use warnings;
use strict;
my $line_changing = <<END_line_changing
1
2
3
END_line_changing
my $tr_format = <<END_TR_FORMAT
<tr>
%s
</tr>
END_TR_FORMAT
foreach my $var_name (qw(foo bar bas)) {
printf $tr_fmt, $var_name;
}