Brandon Fosdick > Finance-OFX > Finance::OFX::Parse

Download:
Finance-OFX-2a.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 2   Source  

NAME ^

Finance::OFX::Parse - Parse the Open Financial Exchange protocol

SYNOPSIS ^

 use Finance::OFX::Parse
 my $tree = Finance::OFX::Parse::parse($ofxContent);

DESCRIPTION ^

Finance::OFX::Parse provides two functions, parse() and parse_file(), that accept an OFX "file" and return a reference to a hash tree representing the contents of the file. parse() expects the OFX content as a scalar argument while parse_file expects a filename.

Parsing well-formed OFX content returns a hash with two keys: 'ofx' and 'header'. The 'ofx' key is a reference to a hash tree representing the <OFX> block and the 'header' key is a reference to a hash of header attributes. All date values are automatically converted to UNIX time.

EXAMPLE

If $ofxContent in the above code is...

 OFXHEADER:100
 DATA:OFXSGML
 VERSION:102
 SECURITY:NONE
 ENCODING:USASCII
 CHARSET:1252
 COMPRESSION:NONE
 OLDFILEUID:NONE
 NEWFILEUID:NONE

 <OFX>
    <SIGNONMSGSRSV1>
        <SONRS>
            <STATUS>
                <CODE>0
                <SEVERITY>INFO
                <MESSAGE>SonRq is successful
            </STATUS>
            <DTSERVER>20080220142819.321[-8:PST]
            <LANGUAGE>ENG
            <FI>
                <ORG>DI
                <FID>074014187
            </FI>
        </SONRS>
    </SIGNONMSGSRSV1>
 </OFX>

...the resulting HoH will be...

 $VAR1 = {
   'ofx' => {
     'signonmsgsrsv1' => {
       'sonrs' => {
         'fi' => {
           'org' => 'DI',
           'fid' => '074014187'
         },
         'language' => 'ENG',
         'status' => {
           'severity' => 'INFO',
           'message' => 'SonRq is successful',
           'code' => '0'
         },
         'dtserver' => '1203546499.321'
       }
     }
   },
   'header' => {
     'CHARSET' => '1252',
     'OFXHEADER' => 100,
     'OLDFILEUID' => 'NONE',
     'COMPRESSION' => 'NONE',
     'SECURITY' => 'NONE',
     'ENCODING' => 'USASCII',
     'NEWFILEUID' => 'NONE',
     'DATA' => 'OFXSGML',
     'VERSION' => '102'
   }
 };

FUNCTIONS ^

$tree = parse($ofx)

parse() accepts a single scalar argument containing the OFX data to be parsed and retunrs a reference to a hash tree.

$tree = parse_file($file_name)

parse_file() accepts a single scalar argument containing the path to a file containing the OFX data to be parsed and retunrs a reference to a hash tree.

SEE ALSO ^

HTML::Parser http://ofx.net

WARNING ^

From Finance::Bank::LloydsTSB:

This is code for online banking, and that means your money, and that means BE CAREFUL. You are encouraged, nay, expected, to audit the source of this module yourself to reassure yourself that I am not doing anything untoward with your banking data. This software is useful to me, but is provided under NO GUARANTEE, explicit or implied.

AUTHOR ^

Brandon Fosdick, <bfoz@bfoz.net>

COPYRIGHT AND LICENSE ^

Copyright 2008 Brandon Fosdick <bfoz@bfoz.net>

This software is provided under the terms of the BSD License.

syntax highlighting: