in reply to Re: reg. expr. multiple substitutions
in thread reg. expr. multiple substitutions
To avoid the quotemeta problem and allow a bit more flexibility, it might make sense to use qr// as described in Regexp Quote Like Operators.
my %subs = ( qr/tag1/ => 'subst1', qr/tag2/ => 'subst2', ... ); $str =~ s[$_][$subs{$_}] for keys %subs;
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: reg. expr. multiple substitutions
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 BrowserUk (Patriarch) on May 17, 2012 at 16:06 UTC | |
by mbethke (Hermit) on May 17, 2012 at 15:38 UTC | |
by BrowserUk (Patriarch) on May 17, 2012 at 15:41 UTC |