Thanks a lot. It works great.
Grace
------------------------------------------------------
-----Original Message-----
From: $Bill Luebkert [mailto:[EMAIL PROTECTED]
Sent: Monday, September 29, 2003 4:04 PM
To: Grace Huang
Cc: [EMAIL PROTECTED]
Subject: Re: how to insert a line in a file
Grace Huang wrote:
> Hi,
>
> I want to insert serveral lines after a line in a file and output the whole new
> file. Is there any way to do this?
> For example: a.txt contains a line which is "this is a test", I want to insert a
> line which is "aaaaaa" after "this is a test".
Finish the ... parts:
open IN, ...
open OUT, ...
while (<IN>) {
if (/this is a test/) { # may need a 'i' suffix for case insensitive match
print OUT;
print OUT "other stuff\n";
next;
}
print OUT;
}
close IN;
close OUT;
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs