So, why does "eq" work like this
Because the internal representation of the two numbers is the same. Just because your code uses different formats to specify them does not affect how they are stored internally. Try this version of your code to see the values:
perl -we '$a = 1e-3; $b = 0.001; if ( $a eq $b ) { print "$a and $b ar +e equal.\n" }'
BTW, try to avoid $a and $b for arbitrary variables in real code because they have special meanings for sorting.
In reply to Re: Why does this string comparison compares "numerically" and can I rely on this in general?
by hippo
in thread Why does this string comparison compares "numerically" and can I rely on this in general?
by Bloehdian
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |