in reply to How do I seek to a certain position in a file?
There really isn't a good way of jumping to a specific line in a file, unless your "lines" are fixed-length. This is because Perl (and your computer in general) thinks of files as a sequence of bytes, not as a sequence of lines.
There are exceptions (one being files with fixed-length records). Take a look at perlfaq5 and the DB_File manpage (in particular, you'll want to look at the DB_RECNO section).
One suggestion in perlfaq5 is to build an index of line numbers mapping to byte positions in the file. Then, when you need to jump to a particular line X, you read the byte position for line X from your index, then seek to that byte position.
This may work for you.
|
|---|