Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Comparing Two Numbers

by davido (Cardinal)
on Jan 05, 2021 at 16:32 UTC ( #11126387=note: print w/replies, xml ) Need Help??


in reply to Comparing Two Numbers

Version::Compare gets it right (right for what you are expecting):

perl -MVersion::Compare -E 'say Version::Compare::version_compare("450 +.80.82","450.57")' 1

It's about 50 lines of code including whitespace and has no non-core dependencies at runtime. I've found it to be able to handle versions such as PHP versions, WordPress versions, and Linux-typical versions.


Dave

Replies are listed 'Best First'.
Re^2: Comparing Two Numbers
by Anonymous Monk on Jan 05, 2021 at 19:56 UTC
    Yep. Once again the wisdom shows itself: "Check CPAN first!" No matter what it is you want to do, someone's probably already done it for you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11126387]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2021-02-27 17:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?