atcroft has asked for the wisdom of the Perl Monks concerning the following question:
Fellow monks, I seek now enlightenment through your knowledge for a problem which has me stumped.
The situation: I have content in a variable which contains POD. I wish to extract the POD from the variable, storing it in another variable.
The problems:
Sample code (uses Find.pm as the target file):
#!/usr/bin/perl -w use Pod::Parser; package MyParser; @ISA = qw(Pod::Parser); use strict; sub command { my ( $parser, $command, $paragraph, $line_num ) = @_; # if ( $command eq 'head1' ) { } # else { } my $expansion = $parser->interpolate( $paragraph, $line_num ); return ($expansion); } sub verbatim { my ( $parser, $paragraph, $line_num ) = @_; return ($paragraph); } sub textblock { my ( $parser, $paragraph, $line_num ) = @_; my $expansion = $parser->interpolate( $paragraph, $line_num ); return ($expansion); } sub interior_sequence { my $self = shift; $self->SUPER->interior_sequence; } package main; use strict; use vars qw(@files); use Data::Dumper; use File::Find; use File::Glob qw(:glob); use Pod::Parser; 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 ); } } my ($content); open( DF, $files[0] ) or die("Can't open $files[0] for input: $!\n"); { local ( $/ = undef ); $content = <DF>; } close(DF); my $parser = new MyParser(); my $text = $parser->parse_text( $content, 0 ); print $text, "\n"; #print Data::Dumper->Dump( [ \$text ], [qw(*text)] ), "\n"; # # # # Output results: # # $ perl test.4.pl # Pod::ParseTree=ARRAY(0x8216778) #
My plea is simple-can someone enlighten me as to my error, or point me in the right direction?
My thanks: To any and all who view this, especially those who put finger to keyboard in responding.
Update: 24 Oct 2004
I appreciate the suggestion, but part of my issue (I think) may be related to subclassing/overriding one or more functions. Any tips/suggestions /etc. regarding this would be appreciated as well.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How best to extract POD from content in one variable, placing it in another variable
by kvale (Monsignor) on Oct 24, 2004 at 02:23 UTC | |
by Anonymous Monk on Oct 28, 2005 at 19:03 UTC | |
|
Re: How best to extract POD from content in one variable, placing it in another variable
by PodMaster (Abbot) on Oct 25, 2004 at 11:04 UTC |