perl -i -wpe 'print "new text\n" if $. == 1;' file #### perl -MTie::File -we 'tie @L, "Tie::File", "file" or die; unshift @L, "new text";'