in reply to Re: Question about speeding a regexp count
in thread Question about speeding a regexp count
This is probably faster:
my %count; my $length = length $seq; for my $i (0 .. $length - 3) { $count{ substr($seq, $i, 1) }++; $count{ substr($seq, $i, 2) }++; $count{ substr($seq, $i, 3) }++; } $count{ substr($seq, $length - 1, 1) }++; $count{ substr($seq, $length - 2, 1) }++; $count{ substr($seq, $length - 2, 2) }++;
Renamed %seen to the more appropriate %count. Renamed $string to $seq to match the OP.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Question about speeding a regexp count
by sauoq (Abbot) on Oct 13, 2005 at 20:08 UTC | |
by ikegami (Patriarch) on Oct 13, 2005 at 20:25 UTC |