http://qs321.pair.com?node_id=685721


in reply to Finding a LCS module on word level

See http://en.wikipedia.org/wiki/Longest_common_substring_problem for a dynamic programming algorithm. You will find a perl implementation in this Wikibooks thing. It is char based, but you can easily make it word based by splitting /\s+/ instead of // (don't forget to change $m and $n as well).

(This is basically what ikegami already said.)