Hi Monks, I've got a bit of a tricky situation here. I'm trying to write a script that will take a list of software packages and compare it to a second list of packages. The second list is a list of available updates. If there is a software package (for isntance, libpng-devel) that exists in both lists, but has a newer version number in the second list, I want to write the newer package name/number to a log file somewhere. So, basically, I'm writing something that checks for software updates and leaves a list of available updates in a logfile for you to find. Here's an example of the two lists:

LIST 1 (currently installed software)
zip-2.3.1-14
xpdf-1.01-8
ggv-1.99.8-2
libpng-devel-1.2.2-8
xvattr-1.3-ogle1

LIST 2 (updates available)
WindowMaker-0.80.1-5
lynx-2.8.5-7.1
xpdf-1.01-10
ggv-1.99.9-5
xvattr-1.4-ogle1
libpng-devel-1.2.2-9

The resulting log file should therefore contain:
xpdf-1.01-10
ggv-1.99.9-5
xvattr-1.4-ogle1
libpng-1.2.2-9

This is tricky since you first have to seperate the version number from the software name, determine if the same software package is listed in both lists, then compare the version numbers of the two--which may contain several dot or dash seperated numbers and/or strings. Is there a simple way to do this (e.g. maybe a version-comparing perl module) or is this going to be one *messy* regex?

In reply to Comparing Version Numbers by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.