in reply to HofA - Sum Totals

There is nothing obviously wrong with this code and I gain no new insight from reading what I presume was the previous node in this thread, Query Array from Hash. Please give some sample input data, or even better the output generated by Dumper (Data::Dumper) so we can compare the data structure you have to the one your code expects.

The my is localizing your result to the implicit for loop. Try this instead:

my $sumcredits = 0; for (@trans_details) { $sumcredits += $_->{'credits'} }

Replies are listed 'Best First'.
Re^2: HofA - Sum Totals
by drodinthe559 (Monk) on Feb 23, 2010 at 21:22 UTC
    That worked. It also worked like the following:
    my $sumcredits = 0; $sumcredits += $_->{'credits'} for (@trans_details);
    So the value in how I had it setup before kept on reinitializing every time it went through the loop. Thanks for your help.