Hi Ron,
Thanks for the suggestion.
At the end, reading the pod file and capturing the key from head1 is easy
(below). I could use a Pod::Simple::SimpleTree , but I would still to have
the output as raw pod. Probably using a parser to select pars of pod is not a
good idea ?
François
my $fname = shift;
my $mod;
open $mod, "<$fname" or die "Can't open $fname $! \n";
my %data;
my $data_ar;
my $key;
my $ispod;
for my $line (<$mod>) {
chomp $line;
if ( $line =~ /^=cut/ ) { $ispod = 0; }
if ( $line =~ /^=head1\s*(.+)$/i ) {
$ispod = 1;
if ($key) { #$key read from the previous =head1
$data{$key} = $data_ar; #store the array of lines as an
array ref
$data_ar = undef; # and prepare a new array
}
$key = $1; #now fetch the new value for $key
}
push @{$data_ar}, $line if ($ispod) ; #store the line in the array
if we are in a pod section
}
close $mod;
$data{$key} = $data_ar; #fetch the lines from the last =head1 read
=for comment
for $key ( keys %data ) {
print "*$key*\n";
print join( "\n", @{ $data{$key} } ), "\n";
}
=cut
return %data;
-----Original Message-----
From: Ron Savage [mailto:[email protected]]
Sent: 28 March 2017 23:36
To: [email protected]
Subject: Re: raw_data with Pod::Simple::PullParser
Hi François
Can't help specifically but I do suggest you use a tree rather than a hash. It
just makes much more sense to me to store the pod that way.
--
Ron Savage - savage.net.au