Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the ^= operator do in Perl?

Tags:

perl

I am searching in the documentation what the ^= assigment operator does.

The only thing I could find so far is:

Other assignment operators work similarly. The following are recognized:

  **=    +=    *=    &=    &.=    <<=    
   -=    /=    |=    |.=   >>=    ||=
   .=    %=    ^=    ^.=   //=    &&=

What is the result of $c ^= $r;?

like image 337
Beginner Avatar asked Dec 11 '22 11:12

Beginner


1 Answers

In Perl ^= is a syntactic sugar for xor operator

$xor_sum = $xor_sum ^ $i;

can be rewritten as

$xor_sum ^= $i;
like image 150
AbhiNickz Avatar answered Jan 03 '23 03:01

AbhiNickz