my $parent = $proteinLU{$word}; my $wIndex = 0; while ($wIndex < @words && exists $parent->{$words[$wIndex]}) { $parent = $parent->{$words[$wIndex++]} } print "**$parent->{_name_}** " if exists $parent->{_name_}; splice @words, 0, $wIndex; #### my $parent = $proteinLU{$word}; my $wIndex = 0; my @best; while ($wIndex < @words && exists $parent->{$words[$wIndex]}) { @best = ($parent->{_name_}, $wIndex) if exists $parent->{_name_}; $parent = $parent->{$words[$wIndex++]}; } if (@best) { print "**$best[0]** "; splice @words, 0, $best[1]; } else { print "$word "; }