in reply to reg. expr. multiple substitutions
Use a hash and a loop:
my %subs = ( tag1 => 'subst1', tag2 => 'subst2', ... ); $str =~ s[$_][$subs{$_}] for keys %subs;
Depending upon the nature of the text involved, you may need to quotemeta some stuff, but that's the basic idea.
Note however, this is only slightly more compact; it will not be quicker or much easier to maintain.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: reg. expr. multiple substitutions
by kennethk (Abbot) on May 17, 2012 at 14:34 UTC | |
by BrowserUk (Patriarch) on May 17, 2012 at 15:06 UTC | |
by kennethk (Abbot) on May 17, 2012 at 15:24 UTC | |
by BrowserUk (Patriarch) on May 17, 2012 at 15:46 UTC | |
by dave_the_m (Monsignor) on May 17, 2012 at 16:01 UTC | |
| |
by mbethke (Hermit) on May 17, 2012 at 15:38 UTC | |
by BrowserUk (Patriarch) on May 17, 2012 at 15:41 UTC |