in reply to Re: Finding common substrings
in thread Finding common substrings

I might be wrong but I think your first method will give a false positive if one string contains a duplicated word but that word doesn't appear in the other string. The $counts{$_} will be more than one but only because the word appeared twice in the same string, not because it was duplicated in the other string.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^3: Finding common substrings
by mreece (Friar) on Sep 21, 2006 at 16:36 UTC
    actually, it won't, because the first foreach only sets to 1 and not ++, and the second foreach only does ++ it if already exists, which means it was already found in $a.
      Doh! I must be going mad :(

      Sorry,

      JohnGG