s/\b([Uu])s\b/$1 eq 'U' ? Them : them/eg; #### $test =~ s/\b([Uu])s\b/$1 eq 'U' ? "Them" : "them"/eg;