in reply to seek in a text file

You could also open the file for reading, read it into an array, close it, filter the values, then open the file for writing (which will create a new file so those old lines won't be hanging around) and write to it.
open my $fh, "data" or die "could not open data for reading: $!"; my @data = <$fh>; close $fh; open $fh, ">data" or die "could not open data for writing: $!"; for (0..4) { print $fh $data[$_]; } close $fh;

Replies are listed 'Best First'.
Re^2: seek in a text file
by ikegami (Patriarch) on Oct 06, 2008 at 01:44 UTC
    That would lose the lock, introducing a race condition.