I want to add a line to top and bottom of the file. I can do it following way.
open (DATA, \"
As Pax says, there is no built-in way to do this. But if you want to do it with a single line perl command from your shell, you can use:
perl -ple 'print "Top line" if $. == 1; if (eof) { print "$_\nBottom line"; exit; }' yourfile.txt > newfile.txt