in reply to insert into beginning of file

One other thing should be mentioned is the -i command line switch. It specifies that using <> operator will edit files in place with an optional extension to rename the input file. See perlrun for the details.

I mentioned this before here.

This will add text to the beginning of temp.txt and back up the current contents of temp.txt to temp.txt.bak

perl -pi.bak -e 'unless ($notfirst++){print "text to add\n";}' temp.t +xt

--

flounder