in my experience this is usually achieved by creating a temporary file
copying the contents of the current file in and making the modifications as
you copy. then deleting the original and renaming the temp file.

So, in your case you'd copy "this is a test" from a.txt to tmp.txt and then
insert your "aaaaaa" in tmp.txt . Copy the rest of a.txt into tmp.txt, then
delete a.txt and rename tmp.txt to a.txt. 

HTH

-Wayne Simmons

> -----Original Message-----
> From: Grace Huang [mailto:[EMAIL PROTECTED]
> Sent: Monday, September 29, 2003 4:39 PM
> To: [EMAIL PROTECTED]
> Subject: how to insert a line in a file
> 
> 
> 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".
> 
> Grace
> ------------------------------------------------------
> 
> 
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to