http://qs1969.pair.com?node_id=276020

c has asked for the wisdom of the Perl Monks concerning the following question:

In cleaning up some old code recently, I found a string that can be summed up as:

if ($val eq '2') { print 'foo'; }

This looked glaringly wrong to me, however it works. In my current perl mindset, I immediately want to change this to:

if ($val == '2') { print 'foo'; }

In my script I am sure that the value of $val will alway be numeric if it is defined at all. However, I'm a bit confused about why == exists if eq works correctly. Reading through perldoc perl, I find the following quote:

(Why do we have separate numeric and string comparisons? Because we don't have special variable types, and Perl needs to know whether to sort numerically (where 99 is less than 100) or alphabetically (where 100 comes before 99)

So does == exist to present a full list of numeric comparison options, when it, unto itself is not necessary?

-c