> Of course, certain values of "fun" =~ "shorter". > > print longest_repeated( 'aabbaaabbbxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxyyyyxyyy' ); > > sub longest_repeated { > my $s = shift; > my $i = 0; > my %longer; > > for ( > sort { $b->[2] <=> $a->[2] } > map { ($i^=1) ? [ substr($_,0,1), $_, length, ] : () } > $s =~ /((.)\2*)/g > ) { > $longer{$_->[0]}++ and not $i and $i = $_->[1]; > } > $i > } > > Now, does anyone else want to argue about Perl being a HLL? ;-) > > John Porter There is lots of fun packed in here (still unpacking some of it), but this it solves a slightly different problem. This finds longest repeated substring of the same character. Substring can be any characters. Once I figure it out, I'll see if I can easily modify it to solve the original problem. Thanks. ==== Want to unsubscribe from Fun With Perl? ==== Well, if you insist... Send mail with body "unsubscribe" to ==== fwp-request@technofile.org