in reply to Question about speeding a regexp count
$seq should be at least 3 chars long.sub roy { my %count; while ($seq =~ /(?=(((.).).))/g) { ++$count{$1}; ++$count{$2}; ++$count{$3}; } # pick up the last two chars $seq =~ /((.)(.))$/; ++$count{$1}; ++$count{$2}; ++$count{$3}; 1; }
|
|---|