I think I'd do it something .like this. If you want all of the blocks they are in @segs.
--#!/usr/bin/perl use strict; use warnings; my $string = 'abbbcddddfegrgrgddeeeeedd'; # Get repeated characters my @segs = $string =~ /((.)\2+)/g; # Filter to get only multi-char strings @segs = grep { length > 1 } @segs; # Sort @segs = sort { length $b <=> length $a } @segs; # Construct answer string my $answer = '-' x index($string, $segs[0]) . $segs[0]; $answer .= '-' x (length($string) - length($answer)); print "$string\n$answer\n";
"The first rule of Perl club is you do not talk about
Perl club."
-- Chip Salzenberg
In reply to Re: Block Search
by davorg
in thread Block Search
by artist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |