| 1 | # Copyright 1999-2019, Paul Johnson (paul@pjcj.net) | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | # This software is free. It is licensed under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | # The latest version of this software should be available from my homepage: | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # http://www.pjcj.net | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | # documentation at __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 15 | require 5.005; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | package Gedcom::Individual; | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 15 | ▶ | use Gedcom::Record 1.21; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 15 | ▶ | use vars qw($VERSION @ISA); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 15 | $VERSION = "1.21"; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 15 | @ISA = qw( Gedcom::Record ); | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | sub name { | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 4713 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 4713 | my $name = $self->tag_value("NAME"); | |||||||||||||||||||||||||||||||||||||||||
| 25 | 4713 | ▶ | return "" unless defined $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 4713 | $name =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 4713 | $name =~ s| ?/ ?(.*?) ?/ ?| /$1/ |; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 4713 | $name =~ s/^\s+//g; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 4713 | $name =~ s/\s+$//g; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 4713 | $name | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | sub cased_name { | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cased_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my $name = $self->name; | |||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | $name =~ s|/([^/]*)/?|uc $1|e; | |||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $name | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | sub surname { | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 4464 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
surname: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 4464 | my ($surname) = $self->name =~ m|/([^/]*)/?|; | |||||||||||||||||||||||||||||||||||||||||
| 43 | 4464 | ▶ | $surname || "" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | sub given_names { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
given_names: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | my $name = $self->name; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $name =~ s|/([^/]*)/?| |; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $name =~ s|^\s+||; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $name =~ s|\s+$||; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $name =~ s|\s+| |g; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $name | |||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 4464 | ▶ | sub soundex { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
soundex: called CC=2 SCAR=8.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 4464 | ▶ | unless ($INC{"Text/Soundex.pm"}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | warn "Text::Soundex.pm is required to use soundex()"; | |||||||||||||||||||||||||||||||||||||||||
| 59 | return undef | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 61 | 4464 | Gedcom::soundex($self->surname) | |||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | sub sex { | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 73 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sex: called CC=4 SCAR=14.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 73 | my $sex = $self->tag_value("SEX"); | |||||||||||||||||||||||||||||||||||||||||
| 67 | 73 | ▶ | defined $sex | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | ? $sex =~ /^F/i ? "F" : $sex =~ /^M/i ? "M" : "U" | ||||||||||||||||||||||||||||||||||||||||||
| 69 | : "U" | ||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | sub father { | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 1433 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
father: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 1433 | my @a = map { $_->husband } $self->famc; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 1433 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | sub mother { | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 1433 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mother: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1433 | my @a = map { $_->wife } $self->famc; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 1433 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | sub parents { | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 1385 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parents: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 1385 | ($self->father, $self->mother) | |||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | sub husband { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 1169 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
husband: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 708 | my @a = grep { $_->{xref} ne $self->{xref} } | |||||||||||||||||||||||||||||||||||||||||
| 92 | 1169 | map { $_->husband } $self->fams; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 1169 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | sub wife { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 1169 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wife: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 756 | my @a = grep { $_->{xref} ne $self->{xref} } | |||||||||||||||||||||||||||||||||||||||||
| 99 | 1169 | map { $_->wife } $self->fams; | |||||||||||||||||||||||||||||||||||||||||
| 100 | 1169 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | sub spouse { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 1145 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spouse: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 1145 | my @a = ($self->husband, $self->wife); | |||||||||||||||||||||||||||||||||||||||||
| 106 | 1145 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | sub siblings { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 1193 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
siblings: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 2148 | my @a = grep { $_->{xref} ne $self->{xref} } | |||||||||||||||||||||||||||||||||||||||||
| 112 | 1193 | map { $_->children } $self->famc; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 1193 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | sub half_siblings { | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
half_siblings: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | my @all_siblings_multiple = | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | map { $_->children } map { $_->fams } $self->parents; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my @excludelist = ($self, $self->siblings); | |||||||||||||||||||||||||||||||||||||||||
| 121 | my @a = grep { | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $cur = $_; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | my $half_sibling = 1; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | for my $test (@excludelist) { | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if ($cur->{xref} eq $test->{xref} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $half_sibling = 0; | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | push @excludelist, $cur if $half_sibling; # to avoid multiple output | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $half_sibling; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } @all_siblings_multiple; | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | sub older_siblings { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
older_siblings: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my @a = map { $_->children } $self->famc; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $i; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | for ($i = 0; $i <= $#a; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | last if $a[$i]->{xref} eq $self->{xref} | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | splice @a, $i; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | wantarray ? @a : $a[-1] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | sub younger_siblings { | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
younger_siblings: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my @a = map { $_->children } $self->famc; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | my $i; | |||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | for ($i = 0; $i <= $#a; $i++) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | last if $a[$i]->{xref} eq $self->{xref} | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | splice @a, 0, $i + 1; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | sub brothers { | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 24 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
brothers: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 24 | my @a = grep { $_->tag_value("SEX") !~ /^F/i } $self->siblings; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 24 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | sub half_brothers { | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
half_brothers: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my @a = grep { $_->tag_value("SEX") !~ /^F/i } $self->half_siblings; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | sub sisters { | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 24 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sisters: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 24 | my @a = grep { $_->tag_value("SEX") !~ /^M/i } $self->siblings; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 24 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | sub half_sisters { | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
half_sisters: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my @a = grep { $_->tag_value("SEX") !~ /^M/i } $self->half_siblings; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | sub children { | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 1457 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
children: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | 1457 | my @a = map { $_->children } $self->fams; | |||||||||||||||||||||||||||||||||||||||||
| 185 | 1457 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | sub sons { | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 24 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sons: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 24 | my @a = grep { $_->tag_value("SEX") !~ /^F/i } $self->children; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 24 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | sub daughters { | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 24 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
daughters: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 24 | my @a = grep { $_->tag_value("SEX") !~ /^M/i } $self->children; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 24 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | sub descendents { | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 24 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
descendents: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 24 | my @d; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 24 | my @c = $self->children; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 24 | ▶ | while (@c) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 48 | push @d, @c; | |||||||||||||||||||||||||||||||||||||||||
| 206 | 48 | @c = map { $_->children } @c; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | @d | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 24 | } | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | sub ancestors { | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 36 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ancestors: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 36 | my @d; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 36 | my @c = $self->parents; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 36 | ▶ | while (@c) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 102 | push @d, @c; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 102 | @c = map { $_->parents } @c; | |||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||
| 219 | @d | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 36 | } | |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | sub delete { | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: called CC=12 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | my $xref = $self->{xref}; | |||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | my $ret = 1; | |||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | for my $f ([ "(HUSB|WIFE)", [$self->fams] ], [ "CHIL", [$self->famc] ]) { | |||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | for my $fam (@{$f->[1]}) { | |||||||||||||||||||||||||||||||||||||||||
| 228 | # print "deleting from $fam->{xref}\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | for my $record (@{$fam->_items}) { | |||||||||||||||||||||||||||||||||||||||||
| 230 | # print "looking at $record->{tag} $record->{value}\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | ▶ | if (($record->{tag} =~ /$f->[0]/) && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$record->{"tag"} =~ /$f->[0]/ and $self->resolve($record->{"value"})->{"xref"} eq $xref
MC/DC100%2/2
$record->{"tag"} =~ /$f->[0]/ and $self->resolve($record->{"value"})->{"xref"} eq $xref
$record->{"tag"} =~ /$f->[0]/
$self->resolve($record->{"value"})->{"xref"} eq $xref
Truth table100%3/3
A and B
A= $record->{"tag"} =~ /$f->[0]/B= $self->resolve($record->{"value"})->{"xref"} eq $xref
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | $self->resolve($record->{value})->{xref} eq $xref) { | ||||||||||||||||||||||||||||||||||||||||||
| 233 | 1 | ▶ | $ret = 0 unless $fam->delete_record($record); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | ▶ | $self->{gedcom}{record}->delete_record($fam) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$fam->tag_value("HUSB") or $fam->tag_value("WIFE") or $fam->tag_value("CHIL")
$fam->tag_value("HUSB") or $fam->tag_value("WIFE")
MC/DC0%0/3
$fam->tag_value("HUSB") or $fam->tag_value("WIFE") or $fam->tag_value("CHIL")
$fam->tag_value("HUSB")
$fam->tag_value("WIFE")
$fam->tag_value("CHIL")
Truth table25%1/4
A or B or C
A= $fam->tag_value("HUSB")B= $fam->tag_value("WIFE")C= $fam->tag_value("CHIL")
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | unless $fam->tag_value("HUSB") || | ||||||||||||||||||||||||||||||||||||||||||
| 238 | $fam->tag_value("WIFE") || | ||||||||||||||||||||||||||||||||||||||||||
| 239 | $fam->tag_value("CHIL"); | ||||||||||||||||||||||||||||||||||||||||||
| 240 | # TODO - write Family::delete ? | ||||||||||||||||||||||||||||||||||||||||||
| 241 | # - delete associated notes? | ||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 1 | ▶ | $ret = 0 unless $self->{gedcom}{record}->delete_record($self); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 1 | ▶ | $_[0] = undef if $ret; # Can't reuse a deleted person | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 1 | $ret | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | sub print { | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | $self->_items if shift; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | $self->SUPER::print; $_->print for @{$self->{items}}; | |||||||||||||||||||||||||||||||||||||||||
| 253 | # print "fams:\n"; $_->print for $self->fams; | ||||||||||||||||||||||||||||||||||||||||||
| 254 | # print "famc:\n"; $_->print for $self->famc; | ||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | sub print_generations { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_generations: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my ($generations, $indent) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | $generations = 0 unless $generations; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | $indent = 0 unless $indent; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | return unless $generations > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my $i = " " x $indent; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | print "$i$self->{xref} (", $self->rin, ") ", $self->name, "\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | unless $indent; | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $self->print; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | for my $fam ($self->fams) { | |||||||||||||||||||||||||||||||||||||||||
| 268 | # $fam->print; | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | for my $spouse ($fam->parents) { | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | next unless $spouse; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | # print "[$spouse]\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | next if $self->xref eq $spouse->xref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | print "$i= $spouse->{xref} (", $spouse->rin, ") ", | |||||||||||||||||||||||||||||||||||||||||
| 274 | $spouse->name, "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | for my $child ($fam->children) { | |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | print "$i> $child->{xref} (", $child->rin, ") ", | |||||||||||||||||||||||||||||||||||||||||
| 278 | $child->name, "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $child->print_generations($generations - 1, $indent + 1); | |||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | sub famc { | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 5187 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
famc: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 5187 | my @a = $self->resolve($self->tag_value("FAMC")); | |||||||||||||||||||||||||||||||||||||||||
| 287 | 5187 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | sub fams { | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 4917 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fams: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 4917 | my @a = $self->resolve($self->tag_value("FAMS")); | |||||||||||||||||||||||||||||||||||||||||
| 293 | 4917 | ▶ | wantarray ? @a : $a[0] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | # FIXME: currently only finds ancestors | ||||||||||||||||||||||||||||||||||||||||||
| 297 | # TODO: find in-laws | ||||||||||||||||||||||||||||||||||||||||||
| 298 | # See http://www.myrelative.com/html/relationship.html for inspiration | ||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||
| 300 | sub relationship { | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 12 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
relationship: called CC=28 SCAR=60.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 12 | my ($other) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||
| 304 | 12 | ▶ | my @ancestors = $self->ancestors() or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 6 | my $sex = $self->sex; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 6 | ▶ | die $self->name, ": unknown sex\n" if $sex eq "U"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 6 | for my $person1 (@ancestors) { | |||||||||||||||||||||||||||||||||||||||||
| 310 | 24 | ▶ | if ($person1 eq $other) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | # Direct ancestor | ||||||||||||||||||||||||||||||||||||||||||
| 312 | 6 | my $steps = $self->_stepsabove($other, 0); | |||||||||||||||||||||||||||||||||||||||||
| 313 | 6 | ▶ | my $title = $sex eq "M" ? "father" : "mother"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 6 | ▶ | if ($steps >= 5) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $steps -= 2; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | return "$steps times great-grand$title"; | |||||||||||||||||||||||||||||||||||||||||
| 317 | } elsif ($steps == 1) { | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | return $title; | |||||||||||||||||||||||||||||||||||||||||
| 319 | } elsif ($steps == 2) { | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 6 | return "grand$title"; | |||||||||||||||||||||||||||||||||||||||||
| 321 | } elsif ($steps == 3) { | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | return "great-grand$title"; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } elsif ($steps == 4) { | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return "great-great-grand$title"; | |||||||||||||||||||||||||||||||||||||||||
| 325 | } elsif ($steps <= 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if (my $spouse = $other->spouse) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | if ($self->_stepsabove($spouse, 0)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | # The caller should now check | ||||||||||||||||||||||||||||||||||||||||||
| 329 | # the spouse's relationship | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | die $other->name, | |||||||||||||||||||||||||||||||||||||||||
| 334 | ": BUG - not a direct ancestor, steps = $steps"; | ||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | my @ancestors2 = $other->ancestors or return; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | for my $person1 (@ancestors) { | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | for my $person2 (@ancestors2) { | |||||||||||||||||||||||||||||||||||||||||
| 343 | # print $person1->name, '->', $person2->name, "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 344 | # G::C is noisy | ||||||||||||||||||||||||||||||||||||||||||
| 345 | # TODO - apparently fixed in Github, awaiting new version on CPAN | ||||||||||||||||||||||||||||||||||||||||||
| 346 | # my $c = Gedcom::Comparison->new($person1, $person2); | ||||||||||||||||||||||||||||||||||||||||||
| 347 | # if($c->identical($person2)) { | ||||||||||||||||||||||||||||||||||||||||||
| 348 | # die 'match found'; | ||||||||||||||||||||||||||||||||||||||||||
| 349 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | if ($person1 eq $person2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | # Common ancestor is $person2 | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | my $steps1 = $self->_stepsabove($person1, 0); | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | return if $steps1 > 7; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $steps2 = $other->_stepsabove($person2, 0); | |||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | return if $steps2 > 7; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | # It would be nice to do this as an algorithm, but this will do | ||||||||||||||||||||||||||||||||||||||||||
| 358 | # e.g. 2, 1 is uncle | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $rel = { | |||||||||||||||||||||||||||||||||||||||||
| 360 | 2 << 8 | 2 => "cousin", | ||||||||||||||||||||||||||||||||||||||||||
| 361 | 2 << 8 | 3 => "first cousin once-removed", | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 3 << 8 | 2 => "first cousin once-removed", | ||||||||||||||||||||||||||||||||||||||||||
| 363 | 2 << 8 | 4 => "first cousin twice-removed", | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 3 << 8 | 3 => "second cousin", | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 3 << 8 | 4 => "second cousin once-removed", | ||||||||||||||||||||||||||||||||||||||||||
| 366 | 4 << 8 | 2 => "first cousin twice-removed", | ||||||||||||||||||||||||||||||||||||||||||
| 367 | 5 << 8 | 2 => "first cousin three-times-removed", | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 5 << 8 | 3 => "second cousin twice-removed", | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 6 << 8 | 3 => "second cousin three-times-removed", | ||||||||||||||||||||||||||||||||||||||||||
| 370 | 6 << 8 | 4 => "third cousin twice-removed", | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 6 << 8 | 5 => "fourth cousin once-removed", | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 7 << 8 | 5 => "fourth cousin twice-removed", | ||||||||||||||||||||||||||||||||||||||||||
| 373 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my $m_rel = { | |||||||||||||||||||||||||||||||||||||||||
| 375 | 1 << 8 | 1 => "brother", | ||||||||||||||||||||||||||||||||||||||||||
| 376 | 1 << 8 | 2 => "nephew", | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 2 << 8 | 1 => "uncle", | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 3 << 8 | 1 => "great-uncle", | ||||||||||||||||||||||||||||||||||||||||||
| 379 | 4 << 8 | 1 => "great-great-uncle", | ||||||||||||||||||||||||||||||||||||||||||
| 380 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my $f_rel = { | |||||||||||||||||||||||||||||||||||||||||
| 382 | 1 << 8 | 1 => "sister", | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 << 8 | 2 => "niece", | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 2 << 8 | 1 => "aunt", | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 3 << 8 | 1 => "great-aunt", | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 4 << 8 | 1 => "great-great-aunt", | ||||||||||||||||||||||||||||||||||||||||||
| 387 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $n = ($steps1 << 8) | $steps2; | |||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | my $rc = $rel->{$n} || ($sex eq "M" ? $m_rel : $f_rel)->{$n}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rel->{$n} || +($sex eq 'M' ? $m_rel : $f_rel)->{$n}
MC/DC0%0/2
$rel->{$n} || +($sex eq 'M' ? $m_rel : $f_rel)->{$n}
$rel->{$n}
+($sex eq 'M' ? $m_rel : $f_rel)->{$n}
Truth table0%0/3
A || B
A= $rel->{$n}B= +($sex eq 'M' ? $m_rel : $f_rel)->{$n}
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | if ($rc && $rc =~ /cousin/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$rc and $rc =~ /cousin/
MC/DC0%0/2
$rc and $rc =~ /cousin/
$rc
$rc =~ /cousin/
Truth table0%0/3
A and B
A= $rcB= $rc =~ /cousin/
| |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my $father = $self->father; | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my $mother = $self->mother; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if ($father && ($father->_stepsabove($person2, 0) > 0)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$father and $father->_stepsabove($person2, 0) > 0
MC/DC0%0/2
$father and $father->_stepsabove($person2, 0) > 0
$father
$father->_stepsabove($person2, 0) > 0
Truth table0%0/3
A and B
A= $fatherB= $father->_stepsabove($person2, 0) > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $rc .= " on your father's side"; | |||||||||||||||||||||||||||||||||||||||||
| 396 | ▶ | } elsif ($mother && ($mother->_stepsabove($person2, 0) > 0)) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$mother and $mother->_stepsabove($person2, 0) > 0
MC/DC0%0/2
$mother and $mother->_stepsabove($person2, 0) > 0
$mother
$mother->_stepsabove($person2, 0) > 0
Truth table0%0/3
A and B
A= $motherB= $mother->_stepsabove($person2, 0) > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $rc .= " on your mother's side"; | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | # print "$steps1, $steps2\n" if(!defined($rc)); | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | return $rc; | |||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | sub _stepsabove { | ||||||||||||||||||||||||||||||||||||||||||
| 409 | 30 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stepsabove: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 30 | my ($target, $count) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 30 | ▶ | return -1 if $count == -1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 30 | ▶ | return $count if $self eq $target; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 24 | my $father = $self->father; | |||||||||||||||||||||||||||||||||||||||||
| 417 | 24 | ▶ | if ($father) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 12 | my $rc = $father->_stepsabove($target, $count + 1); | |||||||||||||||||||||||||||||||||||||||||
| 419 | 12 | ▶ | return $rc unless $rc == -1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 24 | my $mother = $self->mother; | |||||||||||||||||||||||||||||||||||||||||
| 423 | 24 | ▶ | if ($mother) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 12 | return $mother->_stepsabove($target, $count + 1); | |||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 12 | -1 | |||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||
| 430 | 15 | 1 | |||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | __END__ | ||||||||||||||||||||||||||||||||||||||||||