Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hi Monks,

I have a list of files like so:

lab1_set1.txt lab1_set2.txt lab2_set1.txt lab2_set2.txt lab3_set2.txt ..... labn.set1.txt labn_set2.txt

for each pair I want to notify the user that the set was paired and notify the user if a set is unpaired.

I currently have the files read into an array. What I don't know is how to set up the regex and use that compare the filenames. My code so far seems off track... the mental block for me is how do I traverse the array and match on a regex condition? My conceptual code below hopefully reveals the deficiency in my thinking...

for (@labsets) { if ($_ ~= /^lab\d{1}/) = [some condition] { print "$_ matched\n!" } else { print "print $_ did not match\n"; }
Thank you all for any pointers and/or insight.

In reply to How to compare elements within an array by doubleqq

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?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-19 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found