jms53 has asked for the wisdom of the Perl Monks concerning the following question:
sub get_transactions { my $transactions_id = shift; my $sql = <<EOSQL # the sql part works EOSQL my $ar = $dbh->selectall_arrayref( $sql, undef, $transactions_id ); my %transactions; for ( @$ar ) { my ($date, $type, $amount, $new_balance) = @$_; %{$transactions{$date}} = ('Date' => $date, 'Type' => $type, 'Amou +nt' => $amount, 'Ending_balance' => $new_balance); } return %transactions; }
which outputs nothing.I have tried using references,my %transac = MyDB->get_transactions( 10000); print Dumper %transac;
#Module: ... return \%transactions; #script my $transac = MyDB->get_transactions( 10000); print Dumper $transac;
I've managed to point the problem to how I'm calling the sub, but haven't managed tog et it to work as expected.
Thank you,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: returning a hash from a module
by choroba (Cardinal) on Feb 28, 2013 at 20:47 UTC | |
by jms53 (Monk) on Mar 01, 2013 at 19:13 UTC | |
|
Re: returning a hash from a module
by blue_cowdawg (Monsignor) on Feb 28, 2013 at 20:18 UTC | |
|
Re: returning a hash from a module
by kcott (Archbishop) on Feb 28, 2013 at 21:47 UTC | |
by jms53 (Monk) on Mar 01, 2013 at 19:09 UTC | |
|
Re: returning a hash from a module
by locked_user sundialsvc4 (Abbot) on Mar 01, 2013 at 04:58 UTC | |
by Lotus1 (Vicar) on Mar 07, 2013 at 19:24 UTC |