From: georgi choumov <[EMAIL PROTECTED]> > Please help me to solve one problem with my perl script ! > I am using this script for reading and changing some strings in HTML > file. But if it reads an big file (over 1 MB) its needed more than 10 > minutes !!! > > How can I optimize the script for a big files ? > > Thanks ! > > > open(READ, "$ARGV[0]"); > > $wholeText = ""; > > while(defined($i = <READ>)) { > $i =~ s/\.Cure/\.fa/g ; > $i =~ s/cure-/fa-/g ; > $i =~ s/class=Cure/class=fa/g ; > $i =~ s/window.name!=\"frSheet\"/false/g ; > $wholeText = join('', $wholeText, $i); > } > open(WRITE,"> $ARGV[1]"); > print WRITE $wholeText; > > close(READ); > close(WRITE);
Change it to : open(READ, "$ARGV[0]"); open(WRITE,"> $ARGV[1]"); while(defined($i = <READ>)) { $i =~ s/\.Cure/\.fa/g ; $i =~ s/cure-/fa-/g ; $i =~ s/class=Cure/class=fa/g ; $i =~ s/window.name!=\"frSheet\"/false/g ; print WRITE $i; } close(READ); close(WRITE); Jenda =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]