in reply to multi find/replace
Where the key in %table is the thing to replace and the value is what to replace it with.$string =~ s/$_/$table{$_}/g for keys %table;
Cheers - L~R
Update: It looks like Enlil and I had about the same idea. The difference is his regex only runs once while mine runs as many times as there are keys in hash. I know that alternation really slows down a regex, but his method is still probably faster overall though you could benchmark it if you wanted to know for sure.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: multi find/replace
by bart (Canon) on Feb 10, 2004 at 21:52 UTC | |
by Limbic~Region (Chancellor) on Feb 10, 2004 at 22:28 UTC |