if (exists $hash{$_}) { foreach my $physh (sort keys %{$hash{$_}[2]}){ next if (!$hash{$_}[2]{$physh}[9]); ... }