in reply to Re^3: index for large text file
in thread index for large text file

So "Q" is not supported on my architecture and my file is 100GB+ with variable length lines. I'm a little confused with your code. is $i the offset?<\p>

If I wanted to rebuild the entire index with the following code what would I change.

sub build_index { my $data_file = shift; my $index_file = shift; my $offset = 0; while (<$data_file>) { print $index_file pack("N", $offset); $offset = tell($data_file); } } sub line_with_index { my $data_file = shift; my $index_file = shift; my $line_number = shift; my $size; my $i_offset; my $entry; my $d_offset; $size = length(pack("N", 0)); $i_offset = $size * ($line_number-1); seek($index_file, $i_offset, 0) or return; read($index_file, $entry, $size); $d_offset = unpack("N", $entry); seek($data_file, $d_offset, 0); return scalar(<$data_file>); }