my %hash = map {$nums[$_] => $sub_data[$_]} 0.. $#nums; my @gp_nums = (0..114); while ((my $key, my $value) = each %hash) { for (my $i=0; $i<@gp_nums; $i++) { if ($gp_nums[$i] == $key) { print "VALUE $value\n"; } } }