in reply to Index a file with pack for fast access
If the rest of your file looks the same, you don't even need an index. Each line that you pasted has 34 characters (assuming that the newline is a single line-feed, and not CR LF as on windows), so to get the $n-th line (and you start counting the lines from 0), you can just do
my $bytes_per_line = 34; my $pos = $line_number * $bytes_per_line; seek(IN, $pos, 0); my $line = <IN>;
If you need to access by the first column (and not line number), subtract the value of the first row before calculating the line number.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Index a file with pack for fast access
by Ineffectual (Scribe) on Dec 16, 2011 at 22:05 UTC |