From 0b06a2b1784df6673ad05c4f573a3ab44f3b3617 Mon Sep 17 00:00:00 2001 From: Nigel Horne Date: Mon, 28 Oct 2024 08:32:14 -0400 Subject: [PATCH] Remove nested if --- gedcom | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/gedcom b/gedcom index 1812362..66501b9 100755 --- a/gedcom +++ b/gedcom @@ -4380,15 +4380,12 @@ sub print_person # may be the case where someone married more than once, # and has a child by a 3rd unknown (or unfound) person if($opts{'w'}) { - if(($numberofchildren - $childrenseen) == 1) { - if($unknown) { - complain({ person => $person, warning => 'One of the parents of ' . $unknown->as_string() . ' is not known'}); - } else { - complain({ person => $person, warning => 'One of the parents of 1 child is not known'}); - } - } else { - complain({ person => $person, warning => 'One of the parents of ' . ($numberofchildren - $childrenseen) . ' children is not known'}); - } + my $children_missing_parents = $numberofchildren - $childrenseen; + my $warning_message = $children_missing_parents == 1 + ? 'One of the parents of ' . ($unknown ? $unknown->as_string() : '1 child') . ' is not known' + : "One of the parents of $children_missing_parents children is not known"; + + complain({ person => $person, warning => $warning_message }); } } else { foreach my $spouse(@spouses) { @@ -4396,9 +4393,7 @@ sub print_person $parentofall = undef; last; } - if($childrenbyspouse{$spouse->xref()}) { - $parentofall = $spouse; - } + $parentofall = $spouse if $childrenbyspouse{$spouse->xref()}; } }