develooper Front page | perl.beginners | Postings from August 2009

Re: iterating over a hash to print it

Thread Previous | Thread Next
From:
Nick Brown
Date:
August 6, 2009 12:37
Subject:
Re: iterating over a hash to print it
Message ID:
e7c8ceec0908061236y3bfc7109oe135b5de6efe9723@mail.gmail.com
Sorry for the late reply.

I actually switched to using:

use Finance::OFX::Parse::Simple;
http://search.cpan.org/dist/Finance-OFX-Parse-Simple/lib/Finance/OFX/Parse/Simple.pm

and this does appear to parse the data.

    my $ofx_parser = Finance::OFX::Parse::Simple->new;
    my $ofx_data   = $ofx_parser->parse_scalar($response->content);

    print Dumper $ofx_data;
    print ${$ofx_data}[0]->account_id;

The print Dumper line seems to output the OFX data just fine.
But due to my inexperience at perl the next line to print the
account_id fails with following error:

Can't call method "account_id" on unblessed reference at
download_statements.pl line 72, <> line 1.

Can anyone suggest the correct way for me to access the account_id?

Thanks,
Nick


2009/7/19 Brandon Fosdick <bfoz@bfoz.net>:
> Sorry I've been too busy lately to pay attention to this thread. Did you get
> your problem sorted out?
>
> BTW, did you trying using the UserAgent class to fetch the statement? The
> Response object was never really meant to be used like that.
>
> Finance::OFX doesn't yet support the latest version of OFX and FI's are
> finally getting around to upgrading, so it's possible your FI is returning
> reports the module can't understand. I haven't worked on this project for
> some time so I imagine it's suffering from bit rot.
>
> Steve Bertrand wrote:
>>
>> Nick Brown wrote:
>>>
>>> 2009/7/16 John W. Krahn <jwkrahn@shaw.ca>:
>>>>
>>>> Nick Brown wrote:
>>>>>
>>>>> On Jul 15, 11:15 am, jwkr...@shaw.ca (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?
>
>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About