References are compared according to some magical numerical values the contain (probably some address of what they refer to, but that's not important). So two references will only ever compare equal using == if they do indeed refer to the same object. However, a reference will compare equal to its numerical value.
Try this in Tye's example...
$rv = \$var; # reference to $var $num = 0+\$var; # NUMERICAL value of $rv # ($num could conceivably occur in your # program "by chance") ref $rv or die; # ASSERT: $rv is a reference !(ref $num) or die; # ASSERT: $num is NOT a reference print $rv == $num, $/; # Prints "1": a reference equals a # number.
In reply to Re: (tye)Re: eq or == with references
by ariels
in thread eq or == with references
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |