Ledger::Parser - Parse Ledger journals


This document describes version 0.05 of Ledger::Parser (from Perl distribution Ledger-Parser), released on 2016-01-12.


 use Ledger::Parser;
 my $ledgerp = Ledger::Parser->new(
     # year              => undef,        # default: current year
     # input_date_format => 'YYYY/MM/DD', # or 'YYYY/DD/MM',

 # parse a file
 my $journal = $ledgerp->read_file("$ENV{HOME}/money.dat");

 # parse a string
 $journal = $ledgerp->read_string(<<EOF);
 ; -*- Mode: ledger -*-
 09/06 dinner
 Expenses:Food          $10.00
 Expenses:Tips         5000.00 IDR ; 5% tip

 2013/09/07 opening balances
 Assets:Mutual Funds:Mandiri  10,305.1234 MFEQUITY_MANDIRI_IAS
 Equity:Opening Balances

 P 2013/08/01 MFEQUITY_MANDIRI_IAS 1,453.8500 IDR
 P 2013/08/31 MFEQUITY_MANDIRI_IAS 1,514.1800 IDR

See Ledger::Journal for available methods for the journal object.


This module parses Ledger journal into Ledger::Journal object. See for more on Ledger, the command-line double-entry accounting system software.

Ledger 3 can be extended with Python, and this module only supports a subset of Ledger syntax, so you might also want to take a look into the Python extension. However, this module can also modify/write the journal, so it can be used e.g. to insert transactions programmatically (which is my use case and the reason I first created this module).

This is an inexhaustive list of things that are not currently supported:

  • Costs & prices

    For example, things like:

     2012-04-10 My Broker
        Assets:Brokerage            10 AAPL @ $50.00
  • Automated transaction

  • Periodic transaction

  • Expression

  • Various commands

    Including but not limited to: assert, C (currency conversion), ...


input_date_format => str ('YYYY/MM/DD' or 'YYYY/DD/MM')

Ledger accepts dates in the form of yearless (e.g. 01/02, 3-12) or with 4-digit year (e.g. 2015/01/02, 2015-3-12). Month and day can be single- or double-digits. Separator is either - or /.

When year is omitted, year will be retrieved from the year attribute.

The default format is month before day (YYYY/MM/DD), but you can also use day before month (YYYY/DD/MM).

year => int (default: current year)

Only used when encountering a date without year.


new(%attrs) => obj

Create a new parser instance.

$ledgerp->read_file($filename) => obj

$ledgerp->read_string($str) => obj


Please visit the project's homepage at


Source repository is at


Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.


perlancar <>


This software is copyright (c) 2016 by

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.