my $find= "find"; my $repl= "@@@@"; $_ = "Find"; print; s/\b($find)\b/ uc($repl) | ( $1 ^ uc($1) ) /eig; print; # @``` # Should be @@@@