On Wed, 2007-06-20 at 17:12 +0530, Nath, Alok (STSD) wrote:
> Hi,
>       Is it possible to read a particular line by line number ?
> 
>       For e.g reading line 3 from a file.
> 
>       I don't want to read each line and count.

No and yes. If it is genuine new random data then no.

If it is fixed length then you can calculate the position and then do a
seek to the position.  (record length +1) * record number (+2 for cr lf
line endings).

You can index before hand.  For example I have a sort process that reads
the file,  does a tell for the position of the records,  the index is
then manipulated and I can read the records in new order by doing a
seek.

-- 
Ken Foskey
FOSS developer


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to