Following on from
adrianh, also consider...
print "==" if $a == ($b * $c);
and of course, the potential confusion with..
$a = "2.0";
print "eq" if $a eq "2"; # Nope
print "==" if $a == 2; # Yup
Basically, not all equality comparisons are string-based.
In
my 'perl mindset',
if $a == "2", where the number is quoted, immediately begs the question as to which type of comparison is wanted...
if $a eq "2" suggests that $a *generally* holds a non-numeric string...maybe part of something like
foreach my $a (split(/\s+/,"my 1 markup 2 scheme where numbers 3 do 2 stuff")),whereas
if $a == 2 suggests that $a *always* holds a number (and
use warnings will then tell me if it doesn't for any reason).
Cheers,
Ben