in reply to advancing in file read
is there a way to advance the file handle so it doesn't re-read the next lineIf you know the line lengths in the file are uniform then using seek allows you to randomly access file contents as opposed to sequential access hence a position in a file can be reached directly without having to go through the file from the beginning, however, that needs you to know the file content details and to account for the effect of buffering (check the above link). Seek has the syntax 'seek FILEHANDLE, POSITION, WHENCE;' WHENCE specifies the interpretation of POSITION, it can be either 0,1, or 2.
Also reading a file via IO modules provides support for seek through the IO::Seekable interface
use IO::File; use IO::Seekable; $|++; # turn off buffering... my $handle = new IO::File; $handle->open("<FileHello.txt")or die("error $!\n"); $handle->seek(12,0); while(<$handle>){ print; } $handle->close;
|
|---|