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.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|
---|
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 |
In Section
Seekers of Perl Wisdom