NAME

Finance::OFX::Parse::Simple - Parse a simple OFX file or scalar

VERSION

Version 0.07

SYNOPSIS

use Finance::OFX::Parse::Simple;

my $parser = Finance::OFX::Parse::Simple->new;

my $data_from_file     = $parser->parse_file("bank-statement.ofx"); # returns a reference to a list of hash references

my $data_from_scalar   = $parser->parse_scalar($ofx_data); 

METHODS

new

Create a new parser object.

parse_file

Takes a filename as an argument, slurps the file into memory, parses it and returns a reference to a list of hash references. Each hash reference contains two keys: 'account_id' which is the account number, and 'transactions' which is a reference to a list of hash references, each containing details for a single transaction.

Returns false if no filename was provided, the file is not a plain file, or the file is not openable.

parse_scalar

Takes a scalar as an argument containing OFX data. Returns a reference to a list of hash references. Each hash reference contains two keys: 'account_id' which is the account number, and 'transactions' which is a reference to a list of hash references, each containing details for a single transaction.

Returns false if no non-empty scalar is provided.

NOTES

The decimal point character (e.g. . or ,) can be configured before parsing OFX data so that it is handled correctly:

If the environment variable MON_DECIMAL_POINT exists then this is used as the decimal point separator. Failing that, the module will try to use the locale setting of the local system, through the POSIX module. As a last resort a . is used as the separator.

If you are working with OFX data from multiple sources, you can control the separator by setting the MON_DECIMAL_POINT environment variable before parsing each dataset, e.g.:

$ENV{MON_DECIMAL_POINT} = '.';
my $transactions_in_america = $parser->parse_file("bank-of-america.ofx");

local $ENV{MON_DECIMAL_POINT} = ',';
my $transactions_in_germany = $parser->parse_file("deutsche-bank.ofx");

AUTHOR

Jeremy Jones, <jjones at cpan.org>

BUGS

This module is designed to be used with OFX bank statements, and does not currently handle the style of OFX files which are produced by credit card companies. Patches to add make this module suitable for use with credit card style files are welcome.

Please report bugs and feature requests through Github at https://github.com/JeremyJones/Finance--OFX--Parse--Simple/issues or through CPAN at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Finance-OFX-Parse-Simple.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Finance::OFX::Parse::Simple

The latest version of this module is available on Github:

http://github.com/JeremyJones/Finance--OFX--Parse--Simple

You can also look for information at:

COPYRIGHT & LICENSE

Copyright 2009-10 Jeremy Jones, all rights reserved.

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