|
|
| laziness, impatience, and hubris | |
| PerlMonks |
Finding the latest available version of a programby tektsu (Acolyte) |
| on Feb 02, 2004 at 20:53 UTC ( #325996=perlquestion: print w/ replies, xml ) | 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. Any ideas? tektsu kiku wa ittoki no haji kikanu wa matsudai no haji
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||