in reply to Re^2: ugly code
in thread ugly code

I don't know whether this is better or not but I tend to use the quotishness of compiled regexen with a localized list separator rather than join.

my $rxPattern; { local $" = q{|}; $rxPattern = qr{(?x) (@{ [ map { quotemeta } keys %map ] }) }; } $string =~ s{$rxPattern}{$map{$1}}g;

I'd be interested to know if this is a sensible approach.

Cheers,

JohnGG