Subject: | Parser not recognizing break between header and content (Fidelity OFX) |
I am processing an OFX response from Fidelity with
my $tree = Finance::OFX::Parse::parse($ofxContent);
and am getting this message from the module:
Use of uninitialized value in subroutine entry at
/usr/local/share/perl/5.10.0/Finance/OFX/Tree.pm line 57.
Use of uninitialized value in string eq at
/usr/local/share/perl/5.10.0/Finance/OFX/Parse.pm line 112.
I have debugged the issue and have found that the problem stems from a
space on the line that separates the header from the content (newlines
shown with $ character)
...
OLDFILEUID:NONE$
NEWFILEUID:D4EC1DC4-42F8-4686-849E-E3F5A6973A4E$
$
<OFX><SIGNONMSGSRSV1><SONRS>$
...
and this line in Parse.pm is not splitting the data into the header and
content in this case.
my ($header, $body) = split /\n\n/, shift, 2;
I couldn't find in the OFX spec if there were any restrictions on this
"blank" line which separates the data, but it certainly appears that
this should be Fidelity's problem to solve (I'll probably have less luck
getting them to correct this issue) (As a side note, Microsoft Money
interprepts this data sucessfully).
I have verified that this modification resolves the issue:
my ($header, $body) = split /\n[\ \t]*\n/, shift, 2;
Dan