Skip Menu |

This queue is for tickets about the Tree-Family CPAN distribution.

Report information
The Basics
Id: 110778
Status: resolved
Priority: 0/
Queue: Tree-Family

People
Owner: Nobody in particular
Requestors: NHORNE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.02
Fixed in: (no value)



Subject: Can't decipher error
I put together a small program with this snippet to see if I could work out how to use your module: my $tree = Tree::Family->new(filename => '/tmp/dddddd'); my $root = Tree::Family::Person->new(name => $firstname); if($mother) { my $m = Tree::Family::Person->new(name => 'Mother'); $root->mom($m); $tree->add_person($m); } if($father) { my $f = Tree::Family::Person->new(name => 'Father'); $root->dad($f); $tree->add_person($f); } $tree->add_person($root); However I get this message which I can't work out how to fix: generation for Tree::Family::Person=SCALAR(0x7f832ff86a50) or Tree::Family::Person=SCALAR(0x7f832ed44170) not set at /Users/njh/perl5/perlbrew/perls/perl-5.23.5/lib/site_perl/5.23.5/Tree/Family.pm line 316, <GEN0> line 133.
Subject: Re: [rt.cpan.org #110778] Can't decipher error
Date: Wed, 30 Dec 2015 13:26:32 -0700
To: Nigel Horne via RT <bug-Tree-Family [...] rt.cpan.org>
From: Brian Duggan <bduggan [...] matatu.org>
Hi Nigel, Show quoted text
> my $tree = Tree::Family->new(filename => '/tmp/dddddd'); > [..]
Show quoted text
> However I get this message which I can't work out how to fix: > > generation for Tree::Family::Person=SCALAR(0x7f832ff86a50) or Tree::Family::Person=SCALAR(0x7f832ed44170) not set at /Users/njh/perl5/perlbrew/perls/perl-5.23.5/lib/site_perl/5.23.5/Tree/Family.pm line 316, <GEN0> line 133. >
What method is producing the above error message? Try adding an explicit call to _set_generations, e.g. $tree->_set_generations() This traverses the tree and calculates a "generation" for each node (e.g. parents of a child are in the same "generation", grandparents are in the same "generation", etc). Brian
Hi Brian, Thanks for your response. After the final add_person() I have a call to print $tree->as_dot(); which was lost in my copy and paste. It is that line which produces the errors. Removing that line stops the errors. Adding the calls to _set_generations didn't help.
Subject: Re: [rt.cpan.org #110778] Can't decipher error
Date: Thu, 31 Dec 2015 08:59:34 -0500
To: Nigel Horne via RT <bug-Tree-Family [...] rt.cpan.org>
From: Brian Duggan <bduggan [...] matatu.org>
I added some values and the program below works. Looks like "first_name", "gender" and "id" are needed to create graphviz output. use Tree::Family; use Tree::Family::Person; use strict; my $firstname = 'Joe'; my $mother = 'Sue'; my $father = 'Bob'; my $tree = Tree::Family->new(filename => '/tmp/dddddd'); my $root = Tree::Family::Person->new(first_name => $firstname, id => "me", gender => "m"); if($mother) { my $m = Tree::Family::Person->new(first_name => $mother, id => "mom", gender => "f"); $root->mom($m); $tree->add_person($m); } if($father) { my $f = Tree::Family::Person->new(first_name => $father, id => "dad", gender => "m"); $root->dad($f); $tree->add_person($f); } $tree->add_person($root); $tree->_set_generations; print $tree->as_dot; Brian
Thanks, but I'm still getting errors such as: Use of uninitialized value in join or string at /Users/njh/perl5/perlbrew/perls/perl-5.23.5/lib/site_perl/5.23.5/Tree/Family.pm line 328, <GEN0> line 69243. Here's the snippet now. Have I missed something? my $tree = Tree::Family->new(filename => '/tmp/dddddd'); my $root = Tree::Family::Person->new(name => $firstname, id => $person->{'xref'}, gender => 'male'); $tree->add_person($root); if($mother) { my $m = Tree::Family::Person->new(name => 'Mother', id => $mother->{'xref'}, gender => 'female'); $root->mom($m); $tree->add_person($m); } if($father) { my $f = Tree::Family::Person->new(name => 'Father', id => $mother->{'xref'}, gender => 'male'); $root->dad($f); $tree->add_person($f); } if(open(my $fout, '|-', "$dot > html/img/" . $person->{'xref'} . '.png')) { $tree->_set_generations(); print $fout, $tree->as_dot(); # RT110778 close $fout;
I just noticed I did name => instead of first_name =>. I corrected that and now things have progressed. I am now seeing: generation for Tree::Family::Person=SCALAR(0x7fefae6984a8) or Tree::Family::Person=SCALAR(0x7fefa9303bf8) not set at /Users/njh/perl5/perlbrew/perls/perl-5.23.5/lib/site_perl/5.23.5/Tree/Family.pm line 316
I added force: $tree->_set_generations(force => 1); And now there are no errors and I have some output! Now to play a bit more. If you're interested, I hope to use your code in github.com/nigelhorne/ged2html
I've changed my logic to add the generations when I add a node. I always know what generation a node is. So it's now working. Might I suggest that the example in your documentation needs to be corrected? Other than that, all is fine, thanks.
Subject: Re: [rt.cpan.org #110778] Can't decipher error
Date: Mon, 4 Jan 2016 12:20:44 -0500
To: Nigel Horne via RT <bug-Tree-Family [...] rt.cpan.org>
From: Brian Duggan <bduggan [...] matatu.org>
Great, thanks for the feedback, and I'll take a look at the other tickets as soon as I have a chance. On Monday, January 4, Nigel Horne via RT wrote: Show quoted text
> Queue: Tree-Family > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=110778 > > > I've changed my logic to add the generations when I add a node. I always know what generation a node is. So it's now working. Might I suggest that the example in your documentation needs to be corrected? Other than that, all is fine, thanks. >