| > 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);

Agreed, however there is more that can be done.  You want
to filter out non-matching lines ASAP, so you apply full
substitutions when there is a good chance of needing one.

I suggest the following for the loop:

while(defined(<READ>)) {

    # Limit substitutions to lines with either "cure" or
"Cure".
    if (/[Cc]ure/) {
         s/\.Cure/\.fa/g;
         s/cure-/fa-/g;
         s/class=Cure/class=fa/g;
    }

    # Limit substitutions to lines with "window.name"
    if (/window\.name/) {
        s/window.name!=\"frSheet\"/false/g;
    }
        
    print WRITE;
}

It's not going to happen _much_ faster than that.  To
increase performance further use C and XS, or remove the /g
modifiers unless you really need them.

Jonathan Paton

PS:  I rarely test scripts before posting... it _should_
work!  If not, a few minor tweaks should make it work.

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

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

Reply via email to