in reply to assignment operator return values

perlop - Assignment Operators may help. The assignment operator returns the object assigned to as an lvalue so your assignement and test is fine.

Update:

I'd be inclined to rewrite that as:

while ( $self ) { $path += $self->get_branch_length if $self = $self->get_parent; } return $path;

DWIM is Perl's answer to Gödel