$dat0 = 'a.txt'; open( DAT, "$dat0" ) || die ("Could not open file!"); @all = ; # I'm not enven sure what perl will do when you open the same file handle # twice without closing, I would assume it would close the first for you, # but it's just bad. open( DAT, ">$dat0" ) || die; # You never write back to @all so you are doing nothing. print DAT @all; close(DAT);