in reply to Re: Sum of values in an array
in thread Sum of values in an array
I was surprised by my $total += $_->{COMP_TOTAL} for @pe_total; so I ran the code. No output generated so I modified the print to print "$^V >$total<"; which prints:
v5.16.3 ><
What is different about the way you are running the sample code? Different Perl verion maybe?
The B::Deparse of the summing line is:
(my $total += $$_{'COMP_TOTAL'}) foreach (@pe_total);
but my Perl foo isn't strong enough to decide if that means $total is local to the loop body or not. The result implies that it is, at least for this version of Perl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Sum of values in an array
by BrowserUk (Patriarch) on Sep 25, 2014 at 21:20 UTC |