When I read your previous node I started working on a Pod::Simple example since that is currently my Pod weapon of choice. However, I couldn't find an easy way to make it do what you wanted. So instead I turned it around and marked all of the code lines and then removed them from the content.

I think that the Pod::Select example above is more elegant, for this case, but here is the Pod::Simple example for the record:

#!/usr/bin/perl -w package MyParser; use Pod::Simple; @ISA = qw(Pod::Simple); use strict; sub new { my $self = shift->SUPER::new(@_); $self->{_lines} = []; # Add a callback for code lines $self->code_handler ( sub { my $line_num = $_[1]; my $parser = $_[2]; # Replace code lines with undef. $parser->{_lines}->[$line_num -1] = undef; return; } ); return $self; } # # Override parse_lines to store a copy of the input. # sub parse_lines { my $self = shift; push @{$self->{_lines}}, @_; $self->SUPER::parse_lines(@_); } # # Filter out the undef lines that replace the code lines. # sub pod_only { my $self = shift; my @pod = grep {defined} @{$self->{_lines}}; print {$self->{'output_fh'}} @pod; return @pod; } 1; # # Back to our scheduled program. # package main; use strict; my $pod; my $parser =MyParser->new(); $parser->parse_file(*DATA); $parser->output_string(\$pod); $parser->pod_only(); print $pod; __DATA__ # Some code my $foo = 'bar'; =head1 This is a B<heading> This is a paragraph. This is a verbatim section. This is I<B<another>> paragraph =cut

--
John.


In reply to Re: Question regardin Pod::Simple usage by jmcnamara
in thread Question regardin Pod::Simple usage 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.