[pm-h] Pod Extract Name
Michael R. Davis
mrdvt92 at yahoo.com
Tue Apr 4 21:27:18 PDT 2017
>> On Mar 31, 2017, at 2:41 PM, Michael R. Davis <mrdvt92 at yahoo.com> wrote:>> I need to pull the pod NAME for all of my .pm files for a report. >> There are so many POD this and that's on CPAN that I cannot find >> a pod parser
> From: Mark Allen <mrallen1 at yahoo.com>> Sounds like you want https://metacpan.org/pod/Pod::Simple::SimpleTree > or something close to that.
Not the cleanest API that I've seen but it works. I'm still surprised there are no OO pod parsers.
perl -e 'use strict;use warnings;use Pod::Simple::SimpleTree;use Data::Dumper qw{Dumper};
while (my $file=shift) { #print "$file\n"; my $pod=Pod::Simple::SimpleTree->new->parse_file($file)->root; #print Dumper($pod); { my @copy = @$pod; while (@copy) { my $object = shift @copy; #print Dumper($object); last if (ref($object) eq "ARRAY" and $object->[0] eq "head1" and $object->[2] eq "NAME"); } my $object = shift @copy; my $text = $object->[2]; print "$file - $text\n"; }}' `find -name "*.p?"
This pulls the pod NAME from 2039 Perl files.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/houston/attachments/20170405/0f26c25a/attachment.html>
More information about the Houston
mailing list