perl comparision - ghdrako/doc_snipets GitHub Wiki
tags:
- perl
- scripting
Perl comparision
| Numeric | String | Meaning |
|---|---|---|
| == | eq | equal |
| != | ne | not equal |
| < | lt | less than |
| > | gt | greater than |
| <= | le | less than or equal |
| >= | ge | greater than or equal |
12.0 == 12 TRUE
"12.0" == 12 TRUE
"12.0" eq 12 FALSE
2 < 3 TRUE
2 lt 3 TRUE
12 > 3 TRUE
12 gt 3 FALSE ! (look out, might not be obvious at first)
"foo" == "" TRUE ! (You get warnings if you used the "warnings" pragmata)
"foo" eq "" FALSE
"foo" == "bar" TRUE ! (You get warnings if you used the "warnings" pragmata)
"foo" eq "bar" FALSE
"foo" == "bar" will be TRUE - both strings start with a letter they will be both converted to 0. 0 == 0 so that's why we get true
"foo" == "" will be TRUE
"foo" eq "bar" FALSE
"foo" eq "" will be FALSE