in reply to Re: Re: Progressive pattern matching
in thread Progressive pattern matching
Here's my solution to what I understood you wanted (using your definitions of $blocks and @motifs:
Does that do what you wanted, or did I misunderstand you?my @results; while ($blocks) { for (my $len = 1;$len <= length $blocks;$len++) { my $search = substr ($blocks, 0, $len); push @results, grep (/$search/, @motif); } #if there is a match, we're done last if @results; #mo match at starting position - try from next pos $blocks = substr ($blocks, 1); }
pike
|
---|
In Section
Seekers of Perl Wisdom