Text::BibTeX - interface to read and parse BibTeX files
use Text::BibTeX; $bibfile = new Text::BibTeX::File "foo.bib" $newfile = new Text::BibTeX::File ">newfoo.bib" while ($entry = new Text::BibTeX::Entry $bibfile) { next unless $entry->parse_ok; . # hack on $entry contents, using various . # Text::BibTeX::Entry methods . $entry->put ($newfile); }
Text::BibTeX is just used to load the Text::BibTeX::File and Text::BibTeX::Entry modules, which are the ones that do all the real work (i.e., reading and parsing BibTeX files). (You shouldn't try to load Text::BibTeX::Entry on its own, though, because Text::BibTeX also loads the C code needed for parsing BibTeX files.)
Text::BibTeX
Text::BibTeX::File
Text::BibTeX::Entry
The above synopsis shows one general approach for reading/parsing/writing BibTeX files; see Text::BibTeX::File and Text::BibTeX::Entry for full details on those two modules and their methods.
There's a memory leak somewhere in the underlying C library, so be careful about processing large amounts of .bib data. This will be fixed in the next release.
Doesn't currently handle @preamble entries.
@preamble
How to deal with macro definitions (@string entries) from the Perl programmer's point of view is still a little fuzzy (and undocumented).
@string
Greg Ward <greg@bic.mni.mcgill.ca>
Copyright (c) 1997 by Gregory P. Ward. All rights reserved. This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The latest version of Text::BibTeX should be available from
ftp://ftp.bic.mni.mcgill.ca/pub/users/greg/
in Text-BibTeX-x.y.tar.gz, where x.y is the version number. You will also find the latest version of btparse, the C library underlying Text::BibTeX, at that location. It's not strictly necessary to get this separately, as the entire btparse distribution is currently included with Text::BibTeX. However, you might mention this to C programmers looking for a BibTeX solution, or indeed to anyone who could use a C solution to bind to high-level languages other than Perl. Also, in the future, I may include with Text::BibTeX only enough of btparse to build Text::BibTeX itself, in which case it could become useful to get the separate btparse distribution (eg. for documentation or examples).
To install Text::BibTeX, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::BibTeX
CPAN shell
perl -MCPAN -e shell install Text::BibTeX
For more information on module installation, please visit the detailed CPAN module installation guide.