my $parser = SomePodProcessor->new;
$parser->set_source( "whatever.pod" );
$parser->run;
Or:
my $parser = SomePodProcessor->new;
$parser->set_source( $some_filehandle_object );
$parser->run;
Or:
my $parser = SomePodProcessor->new;
$parser->set_source( \$document_source );
$parser->run;
Or:
my $parser = SomePodProcessor->new;
$parser->set_source( \@document_lines );
$parser->run;
And elsewhere:
require 5;
package SomePodProcessor;
use strict;
use base qw(Pod::Simple::PullParser);
sub run {
my $self = shift;
Token:
while(my $token = $self->get_token) {
...process each token...
}
}
This class is for using Pod::Simple to build a Pod processor -- but
one that uses an interface based on a stream of token objects,
instead of based on events.
This is a subclass of the Pod::Simple manpage and inherits all its methods.
This returns the next token object (which will be of a subclass of
the Pod::Simple::PullParserToken manpage), or undef if the parser-stream has hit
the end of the document.
For those to work, the Pod-processing subclass of Pod::Simple::PullParser has to have defined a $parser->run method --
so it is advised that all Pod::Simple::PullParser subclasses do so.
See the Synopsis above, or the source for Pod::Simple::RTF.
Authors of formatter subclasses might find these methods useful to
call on a parser object that you haven't started pulling tokens
from yet:
This tries to get the title string out of $parser, by getting some tokens,
and scanning them for the title, and then ungetting them so that you can
process the token-stream from the beginning.
For example, suppose you have a document that starts out:
=head1 NAME
Hoo::Boy::Wowza -- Stuff B<wow> yeah!
$parser->get_title on that document will return ``Hoo::Boy::Wowza --
Stuff wow yeah!''.
In cases where get_title can't find the title, it will return empty-string
(``'').
This works like get_title except that it returns the contents of the
``=head1 AUTHOR\n\nParagraph...\n'' section, assuming that that section
isn't terribly long.
(This method tolerates ``AUTHORS'' instead of ``AUTHOR'' too.)
This works like get_title except that it returns the contents of the
``=head1 PARAGRAPH\n\nParagraph...\n'' section, assuming that that section
isn't terribly long.
This works like get_title except that it returns the contents of
the ``=head1 VERSION\n\n[BIG BLOCK]\n'' block. Note that this does NOT
return the module's $VERSION!!
You don't actually have to define a run method. If you're
writing a Pod-formatter class, you should define a run just so
that users can call parse_file etc, but you don't have to.
And if you're not writing a formatter class, but are instead just
writing a program that does something simple with a Pod::PullParser
object (and not an object of a subclass), then there's no reason to
bother subclassing to add a run method.
Copyright (c) 2002 Sean M. Burke. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
This program is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of
merchantability or fitness for a particular purpose.