---
name: "Dpkg::Changelog"
section: "3perl"
platform: "linux"
package: "dpkg"
version: "1.23.11-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/Dpkg::Changelog/3perl"
---

# Dpkg::Changelog(3perl)

base class to implement a changelog parser

## NAME

Dpkg::Changelog - base class to implement a changelog parser

## DESCRIPTION

Dpkg::Changelog is a class representing a changelog file as an array of changelog entries (Dpkg::Changelog::Entry). By deriving this class and implementing its **parse()** method, you add the ability to fill this object with changelog entries.

## METHODS

- $chlog = Dpkg::Changelog-\>new(%opts)

  Creates a new changelog object.

  Accepts the same options as `$chlog`-\>**set\_options()**.

- $chlog-\>set\_options(%opts)

  Change the value of some options.

  Options:

  - **verbose**

    Defines whether parse errors are displayed as warnings by default.

    Defaults to 1.

  - **reportfile**

    A string to use instead of the name of the file parsed, in particular in error messages.

  - **range**

    Defines the range of entries that we want to parse, the parser will stop as soon as it has parsed enough data to satisfy `$chlog`-\>get\_range($opts{range}).

- $count = $chlog-\>parse($fh, $description)

  Read the filehandle and parse a changelog in it. The data in the object is reset before parsing new data.

  Returns the number of changelog entries that have been parsed with success.

  This method needs to be implemented by one of the specialized changelog format subclasses.

- $count = $chlog-\>load($filename)

  Parse `$filename` contents for a changelog.

  Returns the number of changelog entries that have been parsed with success.

- $chlog-\>**reset\_parse\_errors()**

  Can be used to delete all information about errors occurred during previous **parse()** runs.

- $chlog-\>parse\_error($file, $line\_nr, $error, \[$line\])

  Record a new parse error in `$file` at line `$line_nr`. The error message is specified with `$error` and a copy of the line can be recorded in `$line`.

- @errors = $chlog-\>**get\_parse\_errors()**

  - $errors = $chlog-\>**get\_parse\_errors()**

  Returns all error messages from the last **parse()** run. If called in scalar context returns a human readable string representation. If called in list context returns an array of arrays. Each of these arrays contains

  - 1\.

    a string describing the origin of the data (a filename usually). If the **reportfile** configuration option was given, its value will be used instead.

  - 2\.

    the line number where the error occurred

  - 3\.

    an error description

  - 4\.

    the original line

- $chlog-\>set\_unparsed\_tail($tail)

  Add a string representing unparsed lines after the changelog entries. Use undef as `$tail` to remove the unparsed lines currently set.

- $string = $chlog-\>**get\_unparsed\_tail()**

  Return a string representing the unparsed lines after the changelog entries. Returns undef if there's no such thing.

- @entries = @{$chlog}

  Returns all the Dpkg::Changelog::Entry objects contained in this changelog in the order in which they have been parsed.

- @entries = $chlog-\>get\_range($range)

  - $entries = $chlog-\>get\_range($range)

  Returns an array (if called in list context) or a reference to an array of Dpkg::Changelog::Entry objects which each represent one entry of the changelog. `$range` is a hash reference describing the range of entries to return. See section "RANGE SELECTION".

- $bool = $chlog-\>**abort\_early()**

  Returns true if enough data have been parsed to be able to return all entries selected by the range set at creation (or with set\_options).

- $string = "$chlog"

  - $string = $chlog-\>**output()**

  Returns a string representation of the changelog (it's a concatenation of the string representation of the individual changelog entries).

- $string = $chlog-\>output($fh)

  Output the changelog to the given filehandle.

- $chlog-\>save($filename)

  Save the changelog in the given file.

- $ctrl\_index = $chlog-\>format\_range($format, $range)

  - @ctrl\_list = $chlog-\>format\_range($format, $range)

  Formats the changelog into Dpkg::Control::Changelog objects representing the entries selected by the optional range specifier (see "RANGE SELECTION" for details). In scalar context returns a Dpkg::Index object containing the selected entries, in list context returns an array of Dpkg::Control::Changelog objects.

  With format **dpkg** the returned Dpkg::Control::Changelog object is coalesced from the entries in the changelog that are part of the range requested, with the fields described below, but considering that "selected entry" means the first entry of the selected range.

  With format **rfc822** each returned Dpkg::Control::Changelog objects represents one entry in the changelog that is part of the range requested, with the fields described below, but considering that "selected entry" means for each entry.

  The different formats return undef if no entries are matched. The following fields are contained in the object(s) returned:

  - Source

    package name (selected entry)

  - Version

    packages' version (selected entry)

  - Distribution

    target distribution (selected entry)

  - Urgency

    urgency (highest of all entries in range)

  - Maintainer

    person that created the (selected) entry

  - Date

    date of the (selected) entry

  - Timestamp

    date of the (selected) entry as a timestamp in seconds since the epoch

  - Closes

    bugs closed by the (selected) entry/entries, sorted by bug number

  - Changes

    content of the (selected) entry/entries

## RANGE SELECTION

A range selection is described by a hash reference where the allowed keys and values are described below.

The following options take a version number as value.

- since

  Causes changelog information from all versions strictly later than **version** to be used.

- until

  Causes changelog information from all versions strictly earlier than **version** to be used.

- from

  Similar to `"since"` but also includes the information for the specified **version** itself.

- to

  Similar to `"until"` but also includes the information for the specified **version** itself.

The following options don't take version numbers as values:

- all

  If set to a true value, all entries of the changelog are returned, this overrides all other options.

- count

  Expects a signed integer as value. Returns `"value"` entries from the top of the changelog if set to a positive integer, and `abs(value)` entries from the tail if set to a negative integer.

- offset

  Expects a signed integer as value. Changes the starting point for `"count"`, either counted from the top (positive integer) or from the tail (negative integer). `"offset"` has no effect if `"count"` wasn't given as well.

Some examples for the above options. Imagine an example changelog with entries for the versions 1.2, 1.3, 2.0, 2.1, 2.2, 3.0 and 3.1.

```
  Range                        Included entries
  -----                        ----------------
  since => '2.0'               3.1, 3.0, 2.2
  until => '2.0'               1.3, 1.2
  from  => '2.0'               3.1, 3.0, 2.2, 2.1, 2.0
  to    => '2.0'               2.0, 1.3, 1.2
  count =>  2                  3.1, 3.0
  count => -2                  1.3, 1.2
  count =>  3, offset => 2     2.2, 2.1, 2.0
  count =>  2, offset => -3    2.0, 1.3
  count => -2, offset => 3     3.0, 2.2
  count => -2, offset => -3    2.2, 2.1
```

Any combination of one option of `"since"` and `"from"` and one of `"until"` and `"to"` returns the intersection of the two results with only one of the options specified.

## CHANGES

### Version 2.00 (dpkg 1.20.0)

Remove methods: `$chlog`-\>**dpkg()**, `$chlog`-\>**rfc822()**.

### Version 1.01 (dpkg 1.18.8)

New method: `$chlog`-\>**format\_range()**.

Deprecated methods: `$chlog`-\>**dpkg()**, `$chlog`-\>**rfc822()**.

New field Timestamp in output formats.

### Version 1.00 (dpkg 1.15.6)

Mark the module as public.
