D. Bolliger wrote:
Michael Oldham am Freitag, 23. Juni 2006 18:20:
[...]

A faster strategy would be:

1. create a lookup hash with the IDs of IDFILE (IDs as keys)
[...]

Doh!

That's right. A hash would be a hundred times faster. Here's the rewrite of my program to use a hash:

#!/usr/bin/perl
use strict;
use warnings;

@ARGV = qw(ids.dat probe.dat);
my $idrx = '\d+\w+';

my %ids;

while (<>) {
    m/^\s*($idrx)\s*$/o && do {
        $ids{$1} = 1;
    };

    m/^>probe:[^:]+:($idrx)/o && do {
        my $id = $1;
        if ($ids{$id}) {
            print $_ . <>;
        }
    };
}



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to