First, you are going to want to google for 'longest common substring' as your brute force approach is definately not the right way to go.

Second, the idiom you don't understand deserves to be in the "Perl Idioms Explained" category. In a nutshell, Perl will do what you mean (DWYM) when you give it proper context. A list in scalar context returns the number of items in the list.

Third - good luck. No matter what algorithm you use (LCS) and what language you use (C/Assembler), this is not going to be a fast answer.

Cheers - L~R

In reply to Re: Longest repeated string... by Limbic~Region
in thread Longest repeated string... by Yzzyx

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":