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.


In reply to Re^2: Need to return the first occurance of a search by mds
in thread Need to return the first occurance of a search by mds

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.