Skip Menu |

This queue is for tickets about the Pod-Usage CPAN distribution.

Maintainer(s)' notes

Please use Github for all future tickets, patches and pull requests: https://github.com/Dual-Life/Pod-Usage

Thanks to Nicolas R (ATOOMIC) for setting up everything there!

Report information
The Basics
Id: 81059
Status: resolved
Worked: 2 hours (120 min)
Priority: 0/
Queue: Pod-Usage

People
Owner: Marek.Rouchal [...] gmx.net
Requestors: david [...] justatheory.com
Cc: jkeenan [...] cpan.org
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.60
Fixed in: 1.65



CC: jkeenan [...] cpan.org
Subject: [RT #115534]: Pod::Usage Failes to Select -sections with Negation
The following bug report was originally filed in the Perl 5 bug queue at https://rt.perl.org/rt3/Ticket/Display.html?id=115534. According to Porting/Maintainers.pl, Pod-Parser, of which Pod::Usage is a component, is primarily maintained on CPAN. I am therefore moving this report to this queue. -- Jim Keenan ##### This is a bug report for perl from david@justatheory.com, generated with the help of perlbug 1.39 running under perl 5.16.1. Given this script: #!/usr/bin/perl -w use strict; use Pod::Usage; my $h2 = shift or die qq{Pass "Foo" or "Bar"\n}; Pod::Usage::pod2usage( '-verbose' => 99, '-exitval' => 1, '-sections' => "Name/$h2/!.+", ); =head1 Name Testing =head2 Foo This is foo =head3 Foo bar This is foo bar. =head2 Bar This is bar. =head3 Bar baz This is bar baz. When passed "Foo", it properly outputs: Foo: This is foo. If it's passed "Bar", it outputs nothing. I expect it to output: Bar: This is bar. I think, but am not sure, that the bug is in _handle_element_end(), where it compares the -sections regular rexpressions to the headers. It appears that Once it hits an `=head3` (in this case, "Foo bar"), it never looks at `=head2` sections again. It skips from "Foo bar" to "Bar baz" without ever looking at "Bar". Note that if I force Pod::Usage to inherit from Pod::PlainText instead of Pod::Text that the bug does not appear. ##### In a follow-up post, I noted that I believe the bug to lie in this part of Pod::Usage::_handle_element_end(): ##### 677 my @headings = @{$$self{USAGE_HEADINGS}}; 678 for my $section_spec ( @{$$self{USAGE_SELECT}} ) { 679 my $match = 1; 680 for (my $i = 0; $i < $Pod::Select::MAX_HEADING_LEVEL; ++$i) { 681 $headings[$i] = '' unless defined $headings[$i]; 682 my $regex = $section_spec->[$i]; 683 my $negated = ($regex =~ s/^\!//); 684 $match &= ($negated ? ($headings[$i] !~ /${regex}/) 685 : ($headings[$i] =~ /${regex}/)); 686 last unless ($match); 687 } # end heading levels 688 if ($match) { 689 $$self{USAGE_SKIPPING} = 0; 690 last; 691 } 692 } # end sections ##### Thank you very much. Jim Keenan
RT-Send-CC: rjbs [...] cpan.org
Jim, I tried to reproduce this with a slightly updated Pod-Parser-1.60 and Pod-Usage-1.60 (find the preliminary distros attached), and with the script found in this ticket, but I cannot reproduce the problem. Both with "Foo" and "Bar" it works nicely, as you expected. I would need more details about the exact versions of Pod-Parser, Pod-Usage, Perl version and platform to know whether this is really a bug. I tested with 5.8.6 on Windows, and 5.6.1 on Windows with SUA. Please test again with the updated distros and tell me which Perl you are using. Oh wait... I just found that a Perl 5.12 shows the same issue... and that's because it is using Pod::Simple for parsing, and not Pod::Parser... so I will have to dig into how Pod::Simple is integrated with Pod::Simple :-/ ... copying rjbs on this ticket... Cheers, Marek
Subject: selectheaders.t
#!/usr/bin/perl -w use strict; use Pod::Usage; print "Pod::Parser is ",$Pod::Parser::VERSION, ", Pod::Usage is ",$Pod::Usage::VERSION,"\n"; my $h2 = shift or die qq{Pass "Foo" or "Bar"\n}; Pod::Usage::pod2usage( '-verbose' => 99, '-exitval' => 1, '-sections' => "Name/$h2/!.+", ); =head1 Name Testing =head2 Foo This is foo =head3 Foo bar This is foo bar. =head2 Bar This is bar. =head3 Bar baz This is bar baz. =cut
Subject: Pod-Parser-1.60.tar.gz
Download Pod-Parser-1.60.tar.gz
application/x-gzip 77.5k

Message body not shown because it is not plain text.

Subject: Pod-Usage-1.60.tar.gz
Download Pod-Usage-1.60.tar.gz
application/x-gzip 17.8k

Message body not shown because it is not plain text.

Found the bug - finally! Will be fixed in Pod-Usage-1.65, coming to CPAN soon.