in reply to Reading HUGE file multiple times
Index the file in one pass; then use the index to seek the id/data directly:
#! perl -slw use strict; my %idx; ## Index the file $idx{ <> } = tell( ARGV ), scalar <> until eof(); for ( 1 .. 1000 ) { my $id = getNextId( ... ); seek ARGV, $idx{ $id }; scalar <>; # discard id line (or verify) print scalar <>; ## access data; }
Untested code for flavour only.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Reading HUGE file multiple times
by Anonymous Monk on Apr 28, 2013 at 10:35 UTC | |
by BrowserUk (Patriarch) on Apr 28, 2013 at 10:45 UTC |