my %subst; @subst{@first_half} = @second_half; s/\Q$_\E/$subst{$_}/ for keys %subst;