Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Massive regexp search and replace

by Anonymous Monk
on Feb 10, 2005 at 15:00 UTC ( #429755=note: print w/ replies, xml ) Need Help??


in reply to Massive regexp search and replace

One problem you have is that you're recompiling the regexes over and over again. Better to cache them. I'd do something like:

# Preprocessing phase. my @subs = map {my($r, $s) = split /\t/; [qr/$r/, $s]} @Patts; # Real stuff. open(my $in, "<", "...") or die "..."; open(my $out, ">", "...") or die "..."; while (<$in>) { s/$_[0]/$_[1]/g for @subs; # No need for /ee, is there? print $out $_; } close $out or die "...";


Comment on Re: Massive regexp search and replace
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://429755]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (14)
As of 2014-10-24 20:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (137 votes), past polls