Reputation: 2783
#!/usr/bin/perl $v = "test"; $v |= "best"; print $v; $v = "test" | "best"; print $v;
How the OR-ing is coming out here is not clear in second case(first case is oring with null seems to be clear ) ?
Upvotes: 0
Views: 421
Reputation: 50637
| is bitwise operator and you wan't to short-circuit string to variable, thus use logical OR ||
|
||
$v ||= "best";
Bitwise calculation for first chars "t" | "b" is same as
"t" | "b"
# 116 | 98 = 118 ("v") print chr(ord("t") | ord("b"));
Upvotes: 4