in reply to Re: multiple (different) substitutions on same $foo
in thread multiple (different) substitutions on same $foo
For a second, I thought you were suggesting what I was going to suggest... Close:
And you can even build the regex from the keys, if you like:my %repl= ( frog=>"toad", man=>"boy", woman=>"girl" ); $foo =~ s/(frog|man|woman)/$repl($1)/g;
But the original code is probably both faster and simpler. (: - tyemy $re= join "|", map quotemeta($_), keys %repl;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re^2: multiple (different) substitutions on same $foo (at once)
by halley (Prior) on Aug 22, 2003 at 12:56 UTC |