my @array; # contains various numbers my %hash = map {$numbers[$_] => $temps[$_]} 0 .. $#numbers; while (($key, $value) = each (%hash)) { if ($key == $array[$_]) { push @found, $key . $value; } }