in reply to retrieving in the correct order
I take it the first array is relatively small? If so, you can just turn your loops inside out:
Notice how you don't even need a regex, just a simple string compare.for my $i (@array2) { for my $line (@array1) { my $key = "gi|$i|"; if (substr($line, 0, length $key) eq $key) { print $line; } } }
If array1 is sorted, you can speed this up a little by remembering where you left off.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: retrieving in the correct order
by Anonymous Monk on Dec 16, 2004 at 20:21 UTC | |
by VSarkiss (Monsignor) on Dec 16, 2004 at 20:47 UTC | |
by Anonymous Monk on Dec 16, 2004 at 21:24 UTC | |
by VSarkiss (Monsignor) on Dec 16, 2004 at 21:39 UTC | |
by Anonymous Monk on Dec 16, 2004 at 21:50 UTC | |
| |
by insaniac (Friar) on Dec 16, 2004 at 21:51 UTC |