From: Tara L Andrews Date: Sun, 5 Feb 2012 21:40:33 +0000 (+0100) Subject: get rid of undefined-value comparison warning X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=008fc8a606dc9e425bbc72b2be2191fee7c7cfde;p=scpubgit%2Fstemmatology.git get rid of undefined-value comparison warning --- diff --git a/lib/Text/Tradition/Collation.pm b/lib/Text/Tradition/Collation.pm index 746504b..a96a789 100644 --- a/lib/Text/Tradition/Collation.pm +++ b/lib/Text/Tradition/Collation.pm @@ -615,13 +615,18 @@ sub _add_edge_weights { # the largest number of witness paths each time. my $weighted = {}; my $curr = $self->start->id; + my $ranked = $self->end->has_rank; while( $curr ne $self->end->id ) { + my $rank = $ranked ? $self->reading( $curr )->rank : 0; my @succ = sort { $self->path_witnesses( $curr, $a ) <=> $self->path_witnesses( $curr, $b ) } $self->sequence->successors( $curr ); my $next = pop @succ; + my $nextrank = $ranked ? $self->reading( $next )->rank : 0; # Try to avoid lacunae in the weighted path. - while( $self->reading( $next )->is_lacuna && @succ ) { + while( @succ && + ( $self->reading( $next )->is_lacuna || + $nextrank - $rank > 1 ) ){ $next = pop @succ; } $weighted->{$curr} = $next;