in reply to Block Search
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Block Search
by artist (Parson) on Oct 04, 2002 at 17:07 UTC | |
by demerphq (Chancellor) on Oct 04, 2002 at 17:13 UTC |