$ perle 'my %x = qw{0 a 1 b 2 c}; say "012" =~ s/([012])/$x{$1}/gr' abc