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:

  1. Most of the modules I have looked at so far seem designed for file-to-file operations, or operations destined for a file.
  2. My humble attempt at subclassing Pod::Parser, attempting to follow its example code, fails for a reason I do not understand.

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.


In reply to How best to extract POD from content in one variable, placing it in another variable by atcroft

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.