in reply to Combining multiple =~ s/

G'day Dave,

"This is cool if there are just a few, but not if a lot. Is there a more compact way to do this?"

If there are "just a few", you can still make this more compact by chaining non-destructive substitution operations. That was introduced in 5.14; see "perl5140delta: Non-destructive substitution".

$string =~ s/zero/0/igr =~ s/one/1/igr =~ s/two/2/igr =~ s/three/3/igr +;

If "a lot", then earlier advice regarding a pattern with alternation and a replacement using a lookup table, would be my choice.

In either case, use a boundary assertion as already described; avoid s/bones/b1s/ and similar mistakes.

— Ken