Subject: | Tree::Simple->setUID returns $uid instead of $self like "normal" Perl setter accessors |
This makes it hard to use this object in an orsacache loop.
recommend
sub setUID {
my ($self, $uid) = @_;
($uid) || die "Insufficient Arguments : Custom Unique ID's must be a true value";
$self->{_uid} = $uid;
return $self; #add this one line!
}
It might also be possible with a different constructor where the uid could be specified on construction.
my $child_tree = $cache{$child_id} ||= Tree::Simple->leaf(uid=>$child_id, node=>$child_id);
But this does NOT work
my $child_tree = $cache{$child_id} ||= Tree::Simple->new($child_id)->setUID($child_id);