Experts,
I am looking to compare elements of 2 array using perl. Below is not the actual code but logic wise something like this.
my $version = "MYSQlcl-5.2.4-264.x86_64"; <-- split this word into array as (5 2 4 264) ( which is to extract only the version number from the package name)
my @array1 = ( 5 2 4 264); <-- after splitting from above
my @array2 = ( 5 3 2 112); <-- pre defined array
if (@array1[0] = @array2[0]) and (@array1[1] = @array2[1]) and (@array1[2] = @array2[2]) and (@array1[3] = @array2[3])
{
print "Same. No upgrade required\n";
}
elsif (@array1[0] > @array2[0]) and (@array1[1] > @array2[1]) and (@array1[2] > @array2[2]) and (@array1[3] > @array2[3])
{
print "Already at higher level. No upgrade required\n";
}
else
{
print "Found at lower version. Upgrade required. Upgrading\n";
}
thanks in advance.