|XP is just a number|
Finding the latest available version of a programby tektsu (Acolyte)
|on Feb 02, 2004 at 20:53 UTC||Need Help??|
tektsu has asked for the
wisdom of the Perl Monks concerning the following question:
I have a hash with the keys being the names and versions of available applications:
Given an application name, I need to find the latest available version. For example, given the hash above, if I have "gcc", I want to return "gcc-3.3.2", "make" should return "make-3.79.1", and "cobol" should return false or undef.
I can do this by sorting the keys in reverse order and looking for the first match for, for example /^gcc-/, but that seems... inefficient.
I know I will need to get get more creative in my sorting (for example, when gcc-10.0 is released), but for now let's assume that cmp gives a correct comparision between versions.
kiku wa ittoki no haji kikanu wa matsudai no haji