#! /usr/bin/perl my %hash = (1 => 2, 2 => 4, 3 => 6); my $sum = 0; foreach my $n(keys %hash) { $sum += $n*$hash{$n}; } print ($sum);