- or download this
my %money_spent = ();
foreach my $customer (keys %myHash) {
$money_spent{$customer} = $myHash{$customer}->{"money"};
}
- or download this
my $money_spent = 0;
foreach my $customer (keys %myHash) {
$money_spent += $myHash{$customer}->{"money"};
}
- or download this
my %money_spent = map { $_ => $myHash{$_}->{"money"} } keys %myHash;
- or download this
use List::Util qw/sum/;
# ...
my $money_spent = sum map { $myHash{$_}->{"money"} } keys %myHash;
- or download this
my %myHash = (
"Fred Flintstone" => {
...
"wife" => "Betty",
},
);