in reply to Specified Line Searching in file!

Under the assumption your "big file" doesn't change that often: create an index of seek/tell values per line.

Sample code without error checking:

open IN, "bigfile.txt"; open IDX, ">bigfile.idx"; binmode IDX; print IDX, pack "N", 0; while(<IN>) { print IDX pack "N", tell IN; }

Now, you can quickly locate line 10000 (the very first line has index 0):

my $lineno = 10000; open IN, "bigfile.txt"; open IDX, "bigfile.idx"; binmode IDX; seek IDX, 4 * $lineno, 0; sysread IDX, (my $buffer), 4; seek IN, unpack("N", $buffer), 0; my $line = <IN>;

This will work as long as your file length of the big file fits into 32 bits.