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).
In reply to Re^3: Replace $a with $b if $a ne $b
by tobyink
in thread Replace $a with $b if $a ne $b
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |