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.