in reply to Re: Re: writing to top of a file
in thread writing to top of a file

Just use File::Copy (more efficient than reading/writing one line at a time):
use File::Temp qw/tempfile/; use File::Copy; my ($fh, $fname) = tempfile(); syswrite $fh, "FIRST LINE\n"; copy($file1, $fh) or die "Error copying: $!"; close $fh;
rename $fname, $file1;