On Friday 29 October 2004 10:35 am, Ing. Branislav Gerzo wrote: > Rajesh Dorairajan [RD], on Thursday, October 28, 2004 at 18:11 > (-0700) thoughtfully wrote the following: > > RD> Does anyone know of a way to open a file in append mode and > append on top of RD> the file? > > I don't think it is possible. You have to read source file, and after > print your results to new file (open through >) and append old file > through >>
It is possible, but very messy. The above method is the most efficient, but does require free disk space equivelent to the the size of the new file. Not usually a problem these days, withthe low cost of HDDs. However, if you do have these restrictions it can be done using the psudocode below calculate write_size seek EOF-buffer_size read buffer_size seek EOF-buffer_size+write_size repeat until at BOF Actually coding this into perl should be fairly easy, and could even be used to insert data mid-file if required. However, if this is something that you're going to be doing regularly, I'd suggest re-evaluating the data format, such as using a database. -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>