PPI icon indicating copy to clipboard operation
PPI copied to clipboard

Pod below __END__ not parsed if __DATA__ section is present

Open mkrull opened this issue 11 years ago • 2 comments

Pod below __END__ is not recognized if a __DATA__ section is present. See #15 for additional info.

use strict;
use warnings;
use feature 'say';
use PPI::Document;

=head1 Test
This is a piece of POD.
=head2 Sub
This is also a piece of POD.
=cut

my $content = '';
{
    local $/;
    open my $fh, '<', $0;
    $content = <$fh>;
    close $0;
}

my $doc = PPI::Document->new(\$content);
my $pod .= PPI::Token::Pod->merge(@{$doc->find('PPI::Token::Pod')});
say $pod;

__DATA__
# some data here
__END__

=head1 More
This should also be a piece of POD. Should it?
=cut

This test script yields:

=pod

=head1 Test
This is a piece of POD.
=head2 Sub
This is also a piece of POD.

=cut

Expected output:

=pod

=head1 Test
This is a piece of POD.
=head2 Sub
This is also a piece of POD.

=head1 More
This should also be a piece of POD. Should it?

=cut

mkrull avatar Dec 27 '13 19:12 mkrull

Thanks a bunch, this is complete enough to make a test and implementation from it. :)

wchristian avatar Dec 27 '13 21:12 wchristian

Confirmed - I noticed this when moving things around in Acme::CPANAuthors::Nonhuman and PodWeaver stopped being able to find any pod.

karenetheridge avatar Jan 25 '14 06:01 karenetheridge