Thanks, Toby. What follows is my first, admittedly crude adaptation of your code to my needs. Suggestions welcome.
Source file: MyConfig.pm
package MyConfig; use strict; use warnings; =head1 NAME MyConfig - Basic configuration data =head1 DESCRIPTION Configuration module. =head1 METHODS =head2 new() Constructor. =cut sub new { my ($class, $args) = @_; return bless $args, $class; } =head1 API Some description of API. =begin apidoc %basic = ( alpha => 'beta', gamma => 'delta', ); =end apidoc More description of API. =begin apidoc %ordinary = ( epsilon => 'zeta', eta => 'theta', ); =end apidoc =head1 SYSTEMS Some description of systems. =begin sysdoc %bold = ( iota => 'kappa', lambda => 'mu', ); =end sysdoc =cut 1;
Program: parse_docs.pl
#!/usr/bin/env perl use strict; use warnings; use 5.010; use Carp; use Data::Dumper;$Data::Dumper::Indent=1; { package Local::Podparser; use parent qw(Pod::Simple::PullParser); our %begins = (); sub _get_titled_section { my $self = shift; my @r; $self->{_in_get_titled_section} = 1; wantarray ? (@r = $self->SUPER::_get_titled_section(@_)) : ($r[0] = $self->SUPER::_get_titled_section(@_)); delete $self->{_in_get_titled_section}; wantarray ? @r : $r[0]; } sub get_token { my $self = shift; my $str = ''; $self->{output_string} = \$str; my $tok = $self->SUPER::get_token; if ( !$self->{_in_get_titled_section} and defined $tok and $tok->[0] eq 'start' and $tok->[1] eq 'for' ) { my $target = $tok->[2]{"target"}; my $data; until ($tok->[0] eq 'end' and $tok->[1] eq 'for') { $data .= $tok->[1] if $tok->[0] eq 'text'; $tok = $self->SUPER::get_token; } push @{$begins{$target}}, $data; $tok = $self->SUPER::get_token; } return $tok; } } my $source = q{./MyConfig.pm}; croak "Could not locate '$source'" unless (-f $source); my $parser = Local::Podparser->new; $parser->set_source( $source ); $parser->accept_targets('apidoc', 'sysdoc'); while (my $token = $parser->get_token()) { # cycle thru the tokens } say STDERR Dumper [ %Local::Podparser::begins ]; say "Finished";
Output: perl parse_docs.pl
$VAR1 = [ 'sysdoc', [ ' %bold = ( iota => \'kappa\', lambda => \'mu\', ); ' ], 'apidoc', [ ' %basic = ( alpha => \'beta\', gamma => \'delta\', ); ', ' %ordinary = ( epsilon => \'zeta\', eta => \'theta\', ); ' ] ]; Finished
Jim Keenan

In reply to Re^2: Pod: Need to parse from =begin ... =end blocks by jkeenan1
in thread Pod: Need to parse from =begin ... =end blocks by jkeenan1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.