What's the the Perl function that achieves the same thing as compareTo
() in Java? I know about eq
and ne
but I want to compare to see if one string is greater than another.
views:
95answers:
2
+5
A:
gt
should do the trick
Edit: actually, cmp
would be more similar to compareTo(), gt
would just tell you if the string is greater than then the other.
cam
2010-08-23 20:34:54
see `perldoc perlop` for all the details
cam
2010-08-23 20:37:37
+17
A:
You actually have cmp
(for strings) and <=>
(for numbers) operators.
See the Equality Operators section in perlop.
Example:
print "foo" cmp "bar"; # prints 1
phadej
2010-08-23 20:37:15