Strip Pod as Pod from Perl file -
Strip Pod as Pod from Perl file -
i trying extract pod documentation perl file. not want convert documentation text done pod::simple::text. want pod text pod text, such can feed pod::template later. example:
use warnings; utilize strict; utilize pod::simple::text; $ps=pod::simple::text->new(); $str; $ps->output_string( \$str ); $ps->parse_file($0); print $str; __end__ =head1 synopsis prog [options] this print pod text. there cpan module can give me pod text, is:
=head1 synopsis prog [options] instead?
update
the solution should able handle pod docs in strings, like
my $str = '__end__ =head1 synopsis';
this can done using ppi:
use strict; utilize warnings; utilize ppi; # slurp source code $src = { local ( @argv, $/ ) = $0; <> }; # load document $doc = ppi::document->new( \$src ); # find pod within doc $pod = $doc->find('ppi::token::pod'); (@$pod) { print $_->content, "\n"; } =comment hi pod =cut 1; __end__ =head1 synopsis prog [options] outputs:
=comment hi pod =cut =head1 synopsis prog [options] perl
Comments
Post a Comment