Closed
Description
Description
The perl parser is supposed to skip over embedded POD sections. The end of a POD section is marked by a =cut
command. However, not every line that starts with =cut
is a =cut
command. For example: =cute
, =cut2
, =cut_dry
.
The perl parser does not correctly recognize these and, in the case of =cute
, behaves differently depending on whether we are in string eval or not.
Steps to Reproduce
use strict;
use warnings;
print "1..9\n";
my $test = 1;
my $foo;
$foo = "";
=pod
=cute
$foo = "not ";
=pod
=cut
print $foo, "ok $test - =cute does not end POD\n";
$test++;
$foo = "";
=pod
=cut2
$foo = "not ";
=pod
=cut
print $foo, "ok $test - =cut2 does not end POD\n";
$test++;
$foo = "";
=pod
=cut_
$foo = "not ";
=pod
=cut
print $foo, "ok $test - =cut_ does not end POD\n";
$test++;
$foo = "not ";
=pod
=cut$cene
$foo = "";
=pod
=cut
print $foo, "ok $test - =cut\$cene ends POD\n";
$test++;
# Same as above, but in string eval.
eval q{
$foo = "";
=pod
=cute
$foo = "not ";
=pod
=cut
print $foo, "ok $test - =cute does not end POD\n";
$test++;
$foo = "";
=pod
=cut2
$foo = "not ";
=pod
=cut
print $foo, "ok $test - =cut2 does not end POD\n";
$test++;
$foo = "";
=pod
=cut_
$foo = "not ";
=pod
=cut
print $foo, "ok $test - =cut_ does not end POD\n";
$test++;
$foo = "not ";
=pod
=cut$cene
$foo = "";
=pod
=cut
print $foo, "ok $test - =cut\$cene ends POD\n";
$test++;
};
print $@ eq "" ? "" : "not ", "ok $test - did not throw an error\n# $@\n";
__END__
Output:
1..9
ok 1 - =cute does not end POD
not ok 2 - =cut2 does not end POD
not ok 3 - =cut_ does not end POD
ok 4 - =cut$cene ends POD
not ok 5 - =cute does not end POD
not ok 6 - =cut2 does not end POD
not ok 7 - =cut_ does not end POD
ok 8 - =cut$cene ends POD
ok 9 - did not throw an error
#
Expected behavior
1..9
ok 1 - =cute does not end POD
ok 2 - =cut2 does not end POD
ok 3 - =cut_ does not end POD
ok 4 - =cut$cene ends POD
ok 5 - =cute does not end POD
ok 6 - =cut2 does not end POD
ok 7 - =cut_ does not end POD
ok 8 - =cut$cene ends POD
ok 9 - did not throw an error
#
Perl configuration
This is with v5.40.0, but it should affect all perl versions (except before 5.8.9 the =cute
test will probably fail without eval, too).