Fellow monks, I humbly return, still seeking enlightenment on handling POD content in the proper manner. As before, I have a variable that contains mixed code/pod content, and this time I have tried to use Pod::Simple. And, as before, I wish to extract the pod content into another variable. The documentation for the module suggested this was feasable, but I am still having no luck with doing so. For testing purposes below, I have had the code search for the copy of Find.pm on the machine, and read it for the input string.
I apologize if I keep asking on this, but it is bothersome that I cannot determine why this is occurring (or not occurring, depending on your point of view). My many thanks to any who can help shed some light on the issue in question, and to those who I have talked to in the CB regarding it previously.
Output:
$ perl test.6.pl
Testing using /usr/lib/perl5/5.8.3/File/Find.pm
Attempt 1:
Content-seen:
1
Original content length: 35380
Content (length=0):
Attempt 2:
Content-seen:
1
Original content length: 35380
Content (length=0):
Source:
#!/usr/bin/perl
use strict;
use vars qw(@files);
use warnings;
use Data::Dumper;
use File::Find;
use File::Glob qw(:glob);
use Pod::Simple;
no warnings
'File::Find'; # per suggestion of the docs for File::Find
$| = 1;
my (@searchpath);
foreach my $i ( 0 .. $#INC ) {
push( @searchpath,
File::Glob::bsd_glob( $INC[$i], GLOB_TILDE | GLOB_ERR )
);
}
find( { wanted => \&wanted, no_chdir => 1 }, @searchpath );
sub wanted {
if ( $File::Find::name =~ m/Find\.pm$/ ) {
push( @files, $File::Find::name );
}
}
print "Testing using ", $files[0], "\n";
print "Attempt 1:\n";
{
my (@content);
open( DF, $files[0] )
or die("Can't open $files[0] for input: $!\n");
{
@content = <DF>;
}
close(DF);
my $podcontent = '';
my $parser = Pod::Simple->new();
$parser->output_string( \$podcontent );
$parser->parse_lines(@content);
$parser->parse_lines(undef);
print "Content-seen:\n", $parser->content_seen, "\n";
print "Original content length: ",
length( join( '', @content ) ), "\n";
print "Content (length=", length($podcontent), "):\n",
$podcontent, "\n";
# print Data::Dumper->Dump( [ \$parser, \@content, \$podcontent ],
# [qw(*parser *content *podcontent)] ), "\n";
}
print "Attempt 2:\n";
{
my ($content);
open( DF, $files[0] )
or die("Can't open $files[0] for input: $!\n");
{
local ( $/ = undef );
$content = <DF>;
}
close(DF);
my $podcontent = '';
my $parser = Pod::Simple->new();
$parser->output_string( \$podcontent );
$parser->parse_string_document($content);
$parser->parse_lines(undef);
print "Content-seen:\n", $parser->content_seen, "\n";
print "Original content length: ", length($content), "\n";
print "Content (length=", length($podcontent), "):\n",
$podcontent, "\n";
# print Data::Dumper->Dump( [ \$parser, \$content, \$podcontent ],
# [qw(*parser *content *podcontent)] ), "\n";
}
Results of 'perl -v': "This is perl, v5.8.3 built for i386-linux-thread-multi"
System is running on Mandrake Linux 10.0
(And yes, this question is in follow-up to that I posted in How best to extract POD from content in one variable, placing it in another variable .)