Only 700 (even if long) rows? Then you don't need any disc-based hash. Just create a hash with the rs value (i.e. for example the 'rs3507865') of a row in file2 as key and the position in the file as data. The position in the file you can find with tell() (before reading the line).
Then just read the numbers in file1 and look up their position in the hash and use seek() in file2 to go there
open(FILE2,... my $position=tell(FILE2); my %rs; while ($line=<FILE2>) { my ($key)= $line=~/^(rs\d{5,})\b/; if (defined $key) { $rs{$key}= $position; } $position=tell(FILE2); } ... while (defined ($line= <FILE>)) { ... foreach (@output) { if (exists $rs{$_}) { seek(FILE2,$rs{$_},0); my $line= <FILE2>; print FD $line; } }
UPDATE: Added a '^' to the regex in the script
In reply to Re^4: General program and related problems
by jethro
in thread General program and related problems
by micky744monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |