I'd approach this by splitting the package names into a hash, and then comparing those:
#!/usr/local/bin/perl -w use strict; my %installed; my %updates; # __DATA__ juggling below is just a kludge to simulate list files while (<DATA>) { my $target=$.>5?\%updates:\%installed; # Regex works on your limited sample, but is quite weak. /(.*?)-(\d.*)/; $target->{$1}=$2; } foreach my $package (keys %updates) { delete $updates{$package} unless (exists $installed{$package} && ($i +nstalled{$package} ne $updates{$package})); } print "Packages to update:"; print join "-", ($_,$updates{$_}), print "\n" for keys %updates; __DATA__ zip-2.3.1-14 xpdf-1.01-8 ggv-1.99.8-2 libpng-devel-1.2.2-8 xvattr-1.3-ogle1 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 __END__ Packages to update: ggv-1.99.9-5-1 xvattr-1.4-ogle1-1 xpdf-1.01-10-1 libpng-devel-1.2.2-9-1
However, the crux of your problem, comparing version numbers, is not dealt with by this - it just spits out the package if it has a different version, not necessarily a higher one. And, as stated in the code, the regex I use is probably easily defeated by some of the more exotic version names (it just splits on the first dash which is followed by a number).

However, this should give you some idea on how to procede.

CU
Robartes-


In reply to Re: Comapring Version Numbers by robartes
in thread 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.