BibTeX::Parser(3pm)

BibTeX::Parser3pm

A pure perl bibtex parser

Usage

Parses BibTeX files.

    use BibTeX::Parser;
        use IO::File;
    my $fh = IO::File->new("filename");
    # Create parser object ...
    my $parser = BibTeX::Parser->new($fh);
    
    # ... and iterate over entries
    while (my $entry = $parser->next ) {
            if ($entry->parse_ok) {
                    my $type    = $entry->type;
                    my $title   = $entry->field("title");
                    my @authors = $entry->author;
                    # or:
                    my @editors = $entry->editor;
                    
                    foreach my $author (@authors) {
                            print $author->first . " "
                                . $author->von . " "
                                . $author->last . ", "
                                . $author->jr;
                    }
            } else {
                    warn "Error parsing file: " . $entry->error;
            }
    }

Functions

new

Creates new parser object.

Parameters:

        * fh: A filehandle

next

Returns the next parsed entry or undef.

Notes

The fields "author" and "editor" are canonicalized, see BibTeX::Parser::Author.

Version

version 1.04

Releases

2 releases since Debian 12 (Bookworm); the text changed 1 time.

  1. 12
  2. 13