|XP is just a number|
reg. expr. multiple substitutionsby silentius (Scribe)
|on May 17, 2012 at 13:18 UTC||Need Help??|
silentius has asked for the
wisdom of the Perl Monks concerning the following question:
For each input string $str I have to test for several possible substitutions, say:
if $str contains tag1 then replace tag1 (in $str) by subst1;
if $str contains tag2 then replace tag2 by subst2;
and so on, and I have 49 such (tag, subst) pairs.
My question, dear and revered and full of wisdom monks, is: could you enlighten me as to a "good" way of programming this?
I mean, do I have any better choice than writing 49 lines like these?:
At least, is there any syntactic sugar for those 49 lines?
Humbly and in much appraisal,