---
name: "BibTeX::Parser::Entry"
section: "3pm"
platform: "linux"
package: "libbibtex-parser-perl"
version: "1.05+dfsg-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/BibTeX::Parser::Entry"
---

# BibTeX::Parser::Entry(3pm)

Contains a single entry of a BibTeX document.

## NAME

BibTeX::Parser::Entry - Contains a single entry of a BibTeX document.

## SYNOPSIS

This class is a wrapper for a single BibTeX entry. It is usually created by BibTeX::Parser.

```
    use BibTeX::Parser::Entry;
    my $entry = BibTeX::Parser::Entry->new($type, $key, $parse_ok, \%fields);

    if ($entry->parse_ok) {
            my $type    = $entry->type;
            my $key     = $enty->key;
            print $entry->field("title");
            my @authors = $entry->author;
            my @editors = $entry->editor;
            ...
            print $entry->to_string;
    }
```

## FUNCTIONS

### new

Create new entry.

### parse\_ok

If the entry was correctly parsed, this method returns a true value, false otherwise.

### error

Return the error message, if the entry could not be parsed or undef otherwise.

### type

Get or set the type of the entry, eg. 'ARTICLE' or 'BOOK'. Return value is  always uppercase.

### key

Get or set the reference key of the entry.

### field($name \[, $value\])

Get or set the contents of a field. The first parameter is the name of the field, the second (optional) value is the new value.

### cleaned\_field($name)

Retrieve the contents of a field in a format that is cleaned of TeX markup.

### cleaned\_author

Get an array of BibTeX::Parser::Author objects for the authors of this entry. Each name has been cleaned of accents and braces.

### cleaned\_editor

Get an array of BibTeX::Parser::Author objects for the editors of this entry. Each name has been cleaned of accents and braces.

### author(\[@authors\])

Get or set the authors. Returns an array of BibTeX::Author  objects. The parameters can either be BibTeX::Author objects or strings.

Note: You can also change the authors with `$entry`-\>field('author', `$authors_string`)

### editor(\[@editors\])

Get or set the editors. Returns an array of BibTeX::Author  objects. The parameters can either be BibTeX::Author objects or strings.

Note: You can also change the authors with `$entry`-\>field('editor', `$editors_string`)

### fieldlist ()

Returns a list of all the fields used in this entry.

### has($fieldname)

Returns a true value if this entry has a value for `$fieldname`.

### pre ()

Return the text in BibTeX file before the entry

### raw\_bibtex ()

Return raw BibTeX entry (if available).

### to\_string (\[options\])

Returns a text of the BibTeX entry in BibTeX format.  Options are a hash.

The return string is the entry reformated with lines indented by 4 spaces and the `@entrytype` uppercased. Example:

```
    @BOOK{Knuth:TAOCP1,
        author = {Knuth, Donald E.},
        publisher = {Addison-Wesley},
        title = {The Art of Computer Programming},
        year = {1968},
        url = {https://www-cs-faculty.stanford.edu/~knuth/taocp.html},
    }
```

- "canonize\_names"

  If true (the default), authors' and editors'  names are translated into canonical bibtex form.  The command  `"$entry->to_string(canonize_names=>0)"` overrides this behavior.

- "field\_capitalization"

  Capitalization of the field names.   Can take values 'Uppercase', 'Lowercase' (the default) or 'Titlecase'

- "print\_pre"

  False by default.  If true, the text in the Bib file before the entry is printed.  Note that at present we assume the text  before the entry NEVER has the @ symbol inside

- "type\_capitalization"

  Capitalization of the type names.   Can take values 'Uppercase' (the default), 'Lowercase' or 'Titlecase'

## VERSION

version 1.05

## AUTHOR

Gerhard Gossen \<gerhard.gossen@googlemail.com\> and Boris Veytsman \<boris@varphi.com\> and Karl Berry \<karl@freefriends.org\>

## COPYRIGHT AND LICENSE

This software is copyright (c) 2013-2024 by Gerhard Gossen and Boris Veytsman and 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.
