How about something like this?
use strict; use warnings; use Data::Dumper; my %totals; for (1 .. 10) { my @plus = (1, 2, 3); @totals{qw(a b c)} = map { $_ + shift @plus } @totals{qw(a b c)}; } print Dumper \%totals;
The map will add the first element of @plus to each element of the slice in order. However, since the first element gets shifted, $totals{a} gets incremented by 1, $totals{b} by 2 and $totals{c} by 3.
In reply to Re: += a hash slice?
by kroach
in thread += a hash slice?
by Random_Walk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |