Java's compareTo() function equivalent in Perl?

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.

Answers


You actually have cmp (for strings) and <=> (for numbers) operators. See the Equality Operators section in perlop.

Example:

print "foo" cmp "bar"; # prints 1

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.


Need Your Help

Getting the time remaining before event.wait is done in Python

python multithreading timer timeout

I'm writing a Python script in which i have a thread running that calculates some values and creates a graph every hour. What I would like to do is have a function in that thread that tells me how ...