$a = 'fred' eq 'fred'; # TRUE $a = 'fred and lucy' eq 'fred' . ' and ' . 'lucy'; # TRUE $a = 'fred' eq $b; # depends on what $b is |
== is for numeric comparison.
eq is for string comparison.
$a = 'fred' == 'lucy'; # WRONG WRONG WRONG! |
$a = 'fred' ne 'fred'; # FALSE $a = 'fred' ne 'lucy'; # TRUE $a = 'fred' eq $b; # depends on what $b is |
String comparison is in ASCII alphabetic order.
$a = 'fred' gt 'lucy'; # FALSE $a = 'fred' lt 'lucy'; # TRUE $a = 'Lucy' lt 'lucy'; # TRUE $a = 'Lucy' lt 'fred'; # TRUE !! |
In ASCII alphabetic order, the set of capital letters is less than the set of lowercase letters.
$result = $a cmp $b |
$result is
|
| Contents |
Next |