Re: pie multiline replace
[email protected] (Gunnar Hjalmarsson)
| Newsgroups | perl.beginners |
|---|---|
| Message-ID | <[email protected]> |
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