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

$a=$b if ($b ne $a);

how can i do this another way, like a:

+=,*=,.=,||=,..., etc

ps: because my variable $a is very long, for example:

$a{aaaaaaa1}{aaaaaaa2}{aaaaaaa3}=$b if ($b ne $a{aaaaaaa1}{aaaaaaa2}{aaaaaaa3});

Thanks beforehand!

Replies are listed 'Best First'.
Re^3: Replace $a with $b if $a ne $b
by tobyink (Canon) on Feb 06, 2013 at 10:49 UTC

    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