coppit has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, Can anyone point me to modules that compare version numbers? There's the version module, but it seems to be oriented only toward Perl-like version numbers. In particular, it doesn't seem to handle version numbers like "1.2b", which I've seen in some GNU software.

Also, I seem to remember a module that supported version dependencies such as "2.0, 2.5-2.7". But for the life of me I can't remember where I saw that. Can someone with a better membory help me out?

Replies are listed 'Best First'.
Re: Modules for comparing version numbers?
by doowah2004 (Monk) on Sep 15, 2004 at 13:15 UTC
    I do not know which of these will work for you, but here are a few modules that come to mind:

    Sort::Version
    File::Version
    Test::Version


    Good Luck,
    Cameron
Re: Modules for comparing version numbers?
by fergal (Chaplain) on Sep 15, 2004 at 13:43 UTC
    only supports the "2.0,2.5-2.7" stuff as in
    use only MyModule => 0.30
    however you might need to install the modules in an "only" friendly way
Re: Modules for comparing version numbers?
by davido (Cardinal) on Sep 15, 2004 at 15:56 UTC

    I used Sort::Versions in a script that I posted here a few months back. The script is used to find whether or not Garmin has posted a newer firmware update for one of its GPS's, or an update to the Mapsource software. The example should be pretty easy to follow, and though you're not comparing Garmin version numbers, the example should give you an idea of how the module works: Check websites for software version updates (ex. Garmin).

    Since then I've used it a few more times to simplify other version-related tasks. It works great. Be sure to read its POD so that you know what to expect the outcome to be with regards to the specific type of version numbers you're comparing.


    Dave

Re: Modules for comparing version numbers?
by ccn (Vicar) on Sep 15, 2004 at 13:07 UTC

    What about string operators lt gt le ge?

    And what version is greater 1.29 or 1.9 ?

Re: Modules for comparing version numbers?
by coppit (Beadle) on Sep 15, 2004 at 13:58 UTC
    It looks like Sort::Versions is exactly what I'm looking for. Thanks for all the pointers!