Fellow Monks,

As you can see my question stems from everyone's favorite perl function: pattern matching. My query is this, how can I take all elements of an array & turn them into search strings which would then be used for pattern matching against another array? In my example, the array @dates would contain anywhere from 2 to 50 elements in the following format; YYYYMMDD. While my second array, @logfiles would contain a list of log file names in the following format; logfile.system_name.YYYYMMDD (This list can contain anywhere from 2 to 200 items). How can I search through @logfiles for any elements that would contain any matches from @dates?

My first thought was to put a for loop inside a for loop, but after thinking about it, this seems like it would be a bit too process intensive for the heavily utilized routine this would be placed in. Any thoughts?

Cheers, Ev

Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.

In reply to create search string from array elements by ministry

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.