test.datファイルの一番上に新しい行を追加してtmp.datに一行ずつ書き込むのは
このようなやり方で問題ないんでしょうか?
$new_line = "新規投稿\n";

open(IN,"test.dat");
open(OUT,">tmp.dat");
print OUT $new_line;

while($line = <IN>){
print OUT $line;
}

close(OUT);
close(IN);