Thank you for your replies.
I think I was overthinking the whole thing.
First of all I need to explain a few more things.
For vaious reasons I can't use the rpm command per package.
All I have is an array of the output of rpm -qa.
Also, The packages I am checking for have already been split
and put into an array. so cups and cups-libs, etc are seperate elements in an array. That piece of information should make this trivial. My apologies for neglecting that.
So I think the following works:
use strict;
use warnings;
my @search_data = qw( cups cups-libs );
my @rpm_data = qw( cups-1.5.2-9.fc16.x86_64 cups-libs-1.5.2-9.fc16.x86
+_64 );
foreach my $patch_prog ( @search_data )
{
my @vers = grep ( /^\Q${patch_prog}\E-\d.*/, @rpm_data );
print "@vers\n";
}
Which is also what hdb and kennethk offered above.
In mine I dont think I need the .* on the end. And I should probably escape the "-". I'm still playing with it. But I think I'm on the right track.
"but what is your intended behavior when the version number changes?"
I will be using RPM::vercmp to compare versions. again the version counterpart to the patch_prog part in the search array is also broken out. so I just need to slice and dice from @rpm_data and then do the RPM::vercmp. So the version changing is expected and hopefully will be handled by the RPM module. Which so far, looks like it is doing a pretty good job.
As far as trying before I posted. For some rason I just could not think of how to write this. I had been looking at so many examples and other solutions I just couldn't see the woods for the trees. Then as soon as I posted the question, The above syntax just dawned on me. *Heavy sigh*
Some days are like that. Thank's again for your prompt and professional replies.
|