On 07/28/2018 08:26 AM, Brandon Allbery wrote:
I think you can use Version.new on that and compare them reasonably
directly? That said, comparison of version numbers is a bit of a
minefield for exactly this reason: not everyone agrees on when to use
string vs. numeric comparison, or what to do when one is numeric and
the other isn't.
Hi Brandon,
I wrote my own routine to test if a revision is greater
than a prior revision. It took two years of thinking
and refining and recently moved it from Perl 5 to Perl 6.
I am working on my program to go the web and update various
programs I support at customer's sites.
You are right about the mine field. Delimiter variations
I have to deal with are
1_2_3_4
1.2.4-4
1.2.3_4
1a10
1b10
1rc10
8u123 (freaking Java)
and so on and so forth.
and is 1.2.3 newer than 1.2.3.0, etc.? (I tag them as identical.)
First I take a,b and rc and adjust them
2.3a5 --> 2.2.4997
2.3b5 --> 2.2.4998
2.3rc5 --> 2.2.4999
Then I do is to first bust both strings into dot only
delimiters.
Next I create number arrays out of each. Then I make sure
both array have the same number of cell by back filling
the short array with zeros.
And finally, I loop across both arrays at the same
time to find if the revision is newer.
As I said, it took me two years of thinking and refining.
If anyone want to see this code, drop me a line. I'd
love to share what I have been up to for the last two years!
-T