On Jul 15, 11:15 am, [email protected] (John W. Krahn) wrote:
> Nick Brown wrote:
> > I'm trying to use Finance::OFX::Response to use a ofx statement I've
> > it downloaded from by bank website.
> >http://search.cpan.org/~bfoz/p5-Finance-OFX-20080303/lib/Finance/OFX/...
> > However there I'm getting the following perl compilation error:
>
> > Type of arg 1 to each must be hash (not subroutine entry) at
> > download_statements.pl line 67, near "->ofx ) "
>
> > for the below code:
>
> > $response = $mech->get($download_url . $count);
> > if (!$response->is_success) {
> > die 'Failed to load statements URL';
> > }
>
> > $response = $mech->submit_form(form_name => $download_form_name, button
> > => \
> > 'btnDownload');
> > if (!$response->is_success) {
> > die 'Failed to get Statement Download';
> > }
>
> > #print $mech->content();
> > my $ofx_response = Finance::OFX::Response->from_http_response($response);
> > while( my ($k, $v) = each $ofx_response->ofx ) {
> > print "key: $k, value: $v.\n";
> > }
>
> > Can you suggest what is wrong the while loop I'm trying to use to
> > print the hash tree of the OFX?
>
> values(), keys() and each() require that their first argument must be a
> hash so if $ofx_response->ofx returns a reference to a hash then you
> have to dereference it:
>
> while( my ($k, $v) = each %{ $ofx_response->ofx } ) {
> print "key: $k, value: $v.\n";
> }
Thanks, I've added the deference to the hash and it now compiles and executes.
However I'm now getting a different run time error:
Odd number of elements in hash assignment at
/usr/lib/perl5/vendor_perl/5.10.0/Finance/OFX/Parse.pm line 105, <>
line 1.
Use of uninitialized value $header{"OFXHEADER"} in numeric eq (==) at
/usr/lib/perl5/vendor_perl/5.10.0/Finance/OFX/Parse.pm line 107, <>
line 1.
Can't use an undefined value as a HASH reference at
download_statements.pl line 67, <> line 1.
Do you have any suggestions to the cause of the this error? What
causing the undefine value as a HASH reference?
Thanks,
Nick
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/