in reply to Comparing Version Numbers
I'm not sure this is possible even for a human to get right on the first try every single time. The package name can end in a number, which may or may not be preceded by what might seem to be a delimiting character (e.g., a hyphen in some cases). How to tell whether that's the end of the package name or the beginning of the version number? Sometimes knowledge of the development cycle of the package in question is required.
Of course, you can ignore those cases and assume that (as is the case for the majority of packages) any numbers separated from the package name by a delimiting character start the version number. That is the approach I would suggest. When it fails, you will just get extraneous entries in your logfile.
Still, comparing version numbers is hard. There is no standard for how they work. I mean, the basics are pretty straightforward (a.b.c.e comes after a.b.c.d if e>d), but a lot of packages do additional esoteric things with their version numbers. Alphas, betas, release candidates, prereleases, ... it's messy. One is tempted to say that alphabetic characters sort after numeric ones which sort after truncatedness, but then what do you do with a version like 3.23.41-5mdk? Ewww, that brings up the issue of forked versions... and what do you do when the same version of something is distributed with different patch options, and the patch options are postpended to the version number? In that case you want the package with the same patch options but the highest version number before them... [suppresses urge to go wash hands]
Still worse, most open-source packages consider the numbers between delimiters as integers, so that (e.g.) 7.11 will sort after 7.10 after 7.9 -- but there are some packages that do version numbering the other way, where 7.11 comes right after 7.1 but before 7.2 (i.e., ASCIIbetical sorting). This is especially common with packages whose lead developers started on platforms other than Unix. (Almost all version numbers in the DOS world were this way, for example, so programmers who used to work on DOS often still number that way.)
for(unpack("C*",'GGGG?GGGG?O__\?WccW?{GCw?Wcc{?Wcc~?Wcc{?~cc' .'W?')){$j=$_-63;++$a;for$p(0..7){$h[$p][$a]=$j%2;$j/=2}}for$ p(0..7){for$a(1..45){$_=($h[$p-1][$a])?'#':' ';print}print$/}
|
|---|