NAME

Text::CommonParts - return the common starting parts of phrases

SYNOPSIS

   use Text::CommonParts qw(common_parts);

   # returns "sheep"
   common_parts("sheep shearing", "sheep dipping", "sheep rustling");

   # returns "sheep", "sheep shearing"
   common_parts("sheep shearing", "sheep dipping", "sheep rustling", "sheep shearing shears");

   # returns "sheep"
   shortest_common_parts("sheep shearing", "sheep dipping", "sheep rustling");

   # returns "sheep"
   shortest_common_parts("sheep shearing", "sheep dipping", "sheep rustling", "sheep shearing shears");

METHODS

common_parts <phrases>

Takes a list of phrases and returns the longest common parts.

If a phrase shares no common parts with any other phrases then it will be returned whole.

Given a set of phrases which have a common prt and a subset of phrases that have a longer common part then both parts will be returned. e.g given

"something good", "something bad", "something in the woodshed", "something in my eye"

will return

"something", "something in"

shortest_common_parts <phrases>

Same as common_parts but will not return subsets. e.g given

"something good", "something bad", "something in the woodshed", "something in my eye"

will just return

"something"

AUTHOR

Simon Wistow <simon@thegestalt.org

COPYRIGHT

Copyright 2006, Simon Wistow

Distributed under the same terms as Perl itself