I have this block of Perl code that I want to simplify. It's part of a subroutine, where a series of arguments are added to values to a hash of hashes.
$user{$account_num}{'item0'} += $item0;
$user{$account_num}{'item1'} += $item1;
$user{$account_num}{'item2'} += $item2;
$user{$account_num}{'item3'} += $item3;
$user{$account_num}{'item4'} += $item4;
$user{$account_num}{'item5'} += $item5;
$user{$account_num}{'item6'} += $item6;
You can see that the variable names are the same as the key names. I seem to remember watching a friend do this kind of thing in one line once. Something like:
[looping through input arguments]:
$user{$account_num}{'variable_name'} += $variable_name;
Does anybody know of a way to do this?