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.
-
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.
|