BibTeX::Parser(3pm)
okay bestie, welcome to the BibTeX::Parser(3pm) page β a User Contributed Perl Documentation situation and a pure-perl BibTeX parser moment β¨
π NAME π
BibTeX::Parser β A pure perl BibTeX parser. That's the whole name, no cap.
β¨ SYNOPSIS β¨
Parses BibTeX files. Here's the literal example from the page, bestie:
use BibTeX::Parser;
use IO::File;
my $fh = IO::File->new("filename");
# Create parser object ...
my $parser = BibTeX::Parser->new($fh, $opts);
# ... and either 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;
}
}
# ... or read all entries at once
$parser->read();
my $num_entries = $parser->n();
my $entrykeys = $parser->entrykeys();
foreach my $key (@{$entrykeys}) {
my $entry = $parser->entry($key);
...
}
if ($parser->has{'thekey') {
$theentry = $parser->entry('thekey');
}
πΈ DESCRIPTION πΈ
There are two interfaces for BiBTeX::Parser: the serial one and the caching one. Yep, BiBTeX::Parser is exactly how it's spelled right there β preserving the lore.
The serial interface can be used for very large files. It reads entries one by one, and outputs them using $parser->next() function. Very one-at-a-time, very snackable.
In other cases you might be better off with the caching interface. It reads all the entries at once, and can output the list of keys or the entry with the given key. Bulk mode, iconic.
π FUNCTIONS π
new π§
Creates new parser object. Constructor main character energy.
Parameters:
fh: A filehandle β the thing the parser reads from.opts: a refernce to the hash of options. (Yes,refernceβ keeping the typo, bestie.) Among other options is'errorlevel', used in the caching interface when processing a non-parseable entry. Can be'warn'(the default),'erorr', or'ignore'. And yes,'erorr'is literally spelled like that β I am not fixing it. Note that in serial interface the error processing is the responsibility of the user.
next π¦
Returns the next parsed entry or undef. One at a time, like a lil treat. Cannot be combined with the read interface described below.
read π
Read all the entries from the filehandle in the internal cache. Bulk mode activated.
n π’
Returns the number of entries after read function has been called. Count 'em.
entrykeys π
Returns the array of keys after read function has been called. All the keys, queued up.
entry ποΈ
Returns an entry with the given key after read function has been called. Pick your fave by key.
Parameters:
key: the key
has β
Returns true if the cached file has the given entry. Vibe check for one specific key.
Parameters:
key: the key
π NOTES π
The fields "author" and "editor" are canonicalized, see BibTeX::Parser::Author. Canonicalized, not chaotic.
π SEE ALSO π
BibTeX::Parser::EntryBibTeX::Parser::Author
β VERSION β
version 1.95 β that's the version, bestie.
π AUTHOR π
Gerhard Gossen <gerhard.gossen@googlemail.com> and Boris Veytsman <boris@varphi.com> and Karl Berry <karl@freefriends.org>
π«Ά COPYRIGHT AND LICENSE π«Ά
Copyright 2013-2026 Gerhard Gossen, Boris Veytsman, Karl Berry
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Free software, free vibes.
xoxo, your BibTeX::Parser(3pm) bestie β footer says perl v5.40.1 and 2026-06-26, so that's the vibe π
π«Ά
π¦ where this page comes from
- ubuntu stonking: libbibtex-parser-perl 1.95+dfsg-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms