in reply to Re: Re: using s/// as map?
in thread how can I speed up this perl??

You're only doing half the work now :-)

You can make it work like this though:

++$count{$1},pos($genome)-- while $genome =~ /\G(..)/g
It's interesting that this is slightly faster than dropping the \G.

This however turns out to be a lot slower (seems to do a complete linear search for the proper string start every time):

$genome =~ /./g; $count{$1}++ while $genome =~ /(.\G.)/g

update This however means that the lookahead version can be speeded up by about 5% too:

$count{$1}++ while $genome =~ /\G(?=(..))./g

Replies are listed 'Best First'.
Re^3a: using s/// as map?
by Roy Johnson (Monsignor) on Nov 24, 2003 at 20:05 UTC
    You're only doing half the work now :-)
    But if I understand gene work (not a certainty at all), I'm doing the half they actually want to do. :-P A molecule isn't paired with both of its neighbors, they are grouped two-by-two.

    At least now I understand why they were doing the lookahead.

    The PerlMonks advocate for tr///