in reply to Replace $a with $b if $a ne $b

For what you say, it seems that this is what you want:

unless ($a =~ /$b/) { $a = $b; }