use File::ReadBackwards; my $listname = shift; ## Not sure whether F::RB allows you to specify an open mode? tie *LIST, 'File::ReadBackwards', $listname or die $!; while( ) { my( $datafile, $position ) = split ' '; my $writePos = tell LIST; truncate LIST, writePos; open DATA, '<', $datafile or die $!; seek DATA, $position, 0 if defined $position; while( ) { seek LIST, $writePos, 0; print LIST ' ', tell( DATA ), "\n"; ## Do stuff with the line from DATA in $_ } close DATA; seek LIST, $writepos, 0; truncate LIST, $writePos; } close LIST; ## Should be empty by the time we get here. unlink $listname;