open(FH,"+<./file.dat") || die("Can't open ./file.dat for reading/writing: $!"); flock(FH,LOCK_EX); seek(FH,0,0); @dat = ; foreach (@dat) {chomp} # this is where I process @dat, and when I feed text # manually into it, it works. the problem doesn't # lie in this segment of the code seek(FH,0,0); print FH join("\n",@dat); flock(FH,LOCK_UN); close(FH);