Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2023-02-02 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (17 votes). Check out past polls.

    Notices?