in reply to Re: check if 2 values are equal
in thread check if 2 values are equal
I think you can do away with the third condition of ($val1 == $val2).
First, the eq should catch differences between numbers equally well as the ==. See Comparing values.
Secondly, the == would fail (under strict) if one of the values were a string.
For eq to work for numbers, you need to know that the values are being represented internally as numbers, for instance:
$a = 1000; $b = 1e3; print $a eq $b ? 1 : 0; > 1 $b = "1e3"; print $a eq $b ? 1 : 0; > 0 $b=$b+0; print $a eq $b ? 1 : 0; > 1
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: check if 2 values are equal
by Corion (Patriarch) on Jan 24, 2006 at 19:35 UTC | |
by clinton (Priest) on Jan 24, 2006 at 19:40 UTC | |
Re^3: check if 2 values are equal
by Happy-the-monk (Canon) on Jan 24, 2006 at 19:38 UTC |
In Section
Seekers of Perl Wisdom