in reply to What is the difference between |= and ||=?
The following sets the var to 1 too, and it even looks similar, so it must be the same operator as the other two, right?
my $var3 = 1;
Why does that bizarre logic keep surfacing? Operators are documented in perlop.
In fact, you should be using my $var = 1; in this case. I'm surprised no one has mentioned that it makes no sense for my $var to be the LHS of |= or ||=.
meansmy $var |= 1; my $var2 ||= 1;
my $var; $var = $var | 1; ^^^^ Known to be undef since it was just created. my $var2; $var2 = $var2 || 1; ^^^^^ Known to be undef since it was just created.
|
|---|