ParaTools 1.00 Documentation - How-To Guides


HOW TO: Modify Converters in Document::Parser::Utils

HOW TO: Create a Document Parser

All new document parsers should be named Biblio::Document::Parser::SomeName, where SomeName is replaced with a unique name (ideally the author's surname). The parser should extend the Biblio::Document::Parser module like so:

 package Biblio::Document::Parser::SomeName;
 require Exporter;
 @ISA = ("Exporter", "Biblio::Document::Parser");
 our @EXPORT_OK = ( 'new', 'parse' );

You should then override the 'new' and 'parse' methods:

e.g.

 sub new
 {
         my($class) = @_;
         my $self = {};
         return bless($self, $class);
 }
 sub parse
 {
        my($self, $lines, %options) = @_;
        # Do something with the lines
        my @lines = split("\n", $lines);
        my @references = get_refs(@lines);
        return @references;
 }

This makes it easy for users to swap out one document parser for another.

 ParaTools 1.00 Documentation - How-To Guides