foreach my $inventors(%{$xml_to_hash->{inventors}}){ if ($inventors->{inventor}->{number}->{content} == 1){ print $inventors->{inventor}; } }