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