in reply to Re^2: Replace $a with $b if $a ne $b
in thread Replace $a with $b if $a ne $b

Just do:

$a = $b;

The if clause is fairly redundant (unless you're concerned about one of the variables being a blessed object which overloads stringification).

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name