sub calcWeight { my($item) = @_; my($weight) = 0; my($part); $numParts = scalar(@parts = getParts($item)); if ( $numParts == 0 ) { return(getWeight($item)); } elsif ( $numParts == 1 ) { return(getWeight($parts[0])); } else { for $part ( @parts ) { $weight += calcWeight($part); } } return($weight); }