Richard Lee wrote:
Gunnar Hjalmarsson wrote:

    perldoc -q "insert a line"

Within that basic form, add the parts that you need to insert, change,
or delete lines.

To prepend lines to the beginning, print those lines before you enter
the loop that prints the existing lines.

       open my $in,  '<',  $file      or die "Can't read old file: $!";
       open my $out, '>', "$file.new" or die "Can't write new file: $!";

       print "# Add this line to the top\n"; # <--- HERE'S THE MAGIC

       while( <$in> )
               {
               print $out $_;
               }

  close $out;

I was just going over this... but shouldn't it be

print $out "# Add this line to the top\n"; # ??? or did I miss something?

I think you are right. I'd suggest that you send a note to Brian d'Foy ([EMAIL PROTECTED]), who is maintaining the FAQ.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to