in reply to Re: Need to return the first occurance of a search
in thread Need to return the first occurance of a search
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.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"; }
"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.
|
|---|