outline.pl untested

filter: Statementstmt 0.0% 0 / 59 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 94 CC 10 SCAR 33.0
CC
10
Cov
0%
do_fam
56.0
do_indi
20.0
BEGIN
2.0
CRAP 27.0
1 #!/usr/local/bin/perl
2  
3 use CGI;
4 use Data::Dumper;
5 use File::Basename;
6 use Roman;
7  
8 use strict;
9  
10 use GedNav::Menu;
11 use GedNav;
12  
13 ## This script is provided as an example.
14 ## It doesn't wrap lines or paginate, but you get what you pay for... :)
15  
16 my $filename = shift || 'royal92';
17 my $indicode = shift || 'I52';
18  
19 my $dataset = new GedNav($filename);
20  
21 my $primary = $dataset->get_indi($indicode);
22  
23 printf "Descendant Tree: %s\n\n", $primary->name_normal;
24  
25 print &do_indi($primary, 0, basename($primary->dataset));
26  
27 print "\n\n";
28  
29 exit;
30  
31 sub do_indi
32 {
33 my $indi = shift;
34 my $depth = shift;
35 my $dataset = shift;
36 my $label = shift;
37  
38 my $html = '';
39  
40 $html .= sprintf "%s%s%s -- ",
41 '. . ' x $depth,
42 ($label) ? "$$label. " : '',
43 $indi->name_normal,
44 ;
45  
46 $html .= sprintf "b: %s, ", $indi->birth->date if $indi->birth;
47 $html .= sprintf "d: %s, ", $indi->death->date if $indi->death;
48  
49 $html .= "\n";
50  
51 my $childcount = 0;
52 foreach ($indi->fams)
53 {
54 $html .= &do_fam($_, $depth, $indi->sex, $dataset, \$childcount);
55 }
56  
57 return $html;
58 }
59  
60 sub do_fam
61 {
62 my $fam = shift;
63 my $depth = shift;
64 my $sex = shift;
65 my $dataset = shift;
66 my $childcount = shift;
67  
68 my $text = '';
69  
70 my $spouse = ($sex =~ /f/i) ? $fam->husb : $fam->wife;
71  
72 if ($spouse)
73 {
74 $text .= sprintf "%s m: %s, %s -- ",
75 '. . ' x $depth,
76 $spouse->name_normal,
77 $fam->marriage ? $fam->marriage->date : '',
78 ;
79  
80 $text .= sprintf "b: %s, ", $spouse->birth->date if $spouse->birth;
81 $text .= sprintf "d: %s, ", $spouse->death->date if $spouse->death;
82  
83 $text .= "\n";
84 }
85  
86 if ($fam->children)
87 {
88 foreach ($fam->children)
89 {
90 ++$$childcount;
91 $text .= &do_indi($_, $depth + 1, $dataset, $childcount);
92 }
93 }
94  
95 return $text;
96 }
97  
98  
99  
100  
101 1;
102  
103