in reply to Comparing Version Numbers
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).#!/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, this should give you some idea on how to procede.
CU
Robartes-
|
|---|