naturalsciences has asked for the wisdom of the Perl Monks concerning the following question:
Is it possible to do multiple substitutions by means of a one-liner. you can add the first part in s/// as a list like
s/(apples|oranges|bananas)/fruit/but if I would like to make a substitution apple > yummy, orange > yummier, banana > yummiest. then I can't just
s/(apples|oranges|bananas)/(yummy|yummier|yummiest)/because it would just replace them all with the full (yummy|yummier|yummiest) not case by case. Is it possible still to get something like this by a somewhat comparably short expression.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: multiple substitution
by Corion (Patriarch) on Aug 25, 2012 at 09:27 UTC | |
by aaron_baugher (Curate) on Aug 25, 2012 at 16:39 UTC | |
by AnomalousMonk (Archbishop) on Aug 25, 2012 at 18:11 UTC | |
by Corion (Patriarch) on Aug 25, 2012 at 16:48 UTC | |
by naturalsciences (Beadle) on Aug 25, 2012 at 10:08 UTC | |
by Corion (Patriarch) on Aug 25, 2012 at 13:20 UTC | |
by AnomalousMonk (Archbishop) on Aug 25, 2012 at 17:28 UTC | |
by cheekuperl (Monk) on Aug 25, 2012 at 13:07 UTC | |
by naturalsciences (Beadle) on Aug 25, 2012 at 09:34 UTC | |
|
Re: multiple substitution
by philiprbrenan (Monk) on Aug 25, 2012 at 23:50 UTC |