in reply to Using += in array context

Take a look at this node where esentially the same question is being asked. Especially usefull to you might be this discussion on mapcar

Replies are listed 'Best First'.
(tye)Re: Using += in array context
by tye (Sage) on Jun 05, 2001 at 18:32 UTC

    Personally, I'd use the foreach code from the original question. I find it clearer and cleaner than even the "wish" code. For one thing, "@fields" doesn't have to be repeated in that code.

    If grinder finds     $totals{$_} += $delta{$_} foreach( @fields ); "ugly", then I doubt

    use mapcar; mapcar { $_[0] += $_[1] } [@totals{@fields}], [@delta{@fields}];
    would fair any better.

            - tye (but my friends call me "Tye")