use warnings; my @change = (1.15, -0.1, 5.4, 1.03, -0.241); my @numberofshares = (100, 400, 200, 300, 240); @hash{@change} = @numberofshares; while (($k, $v) = each %hash) { foreach ($v1) { $product = $v1*$k1 } }