my $new_file;
open(FILE,'<file.txt') or die "Can't open file.txt: $!\n";
while(my $line=<FILE>) {
  $line=~s/WORD_TO_REPLACE/REPLACEMENT_WORD/g;
  $new_file.=$line;
}
close(FILE);
open(FILE,'>new_file.txt') or die "Can't write new_file.txt: $!\n";
print FILE $new_file;
close(FILE)

I do something like this. Hope it helps....

>----- Original Message -----
>From: "Rajanikanth Dandamudi" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Thursday, March 21, 2002 1:25 PM
>Subject: Help Required - Search and Replace
>
>
> > All,
> >
> > I have a one big text file and also I have some set of strings to be
> > replaced by another set of strings. Currently, I am reading each line of
> > the file, and replacing one set of strings by another set of strings,
> > one after another. Is there any efficient way of doing this? The data is
> > so huge that this job takes around 7Hrs of total time on Sun Ultra 10.
> > Is there any way of efficiently doing this? Thanks in advance.
> >
> > Thanks and Regards,
> > D.Rajanikanth
> >
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to