doubleqq has asked for the wisdom of the Perl Monks concerning the following question:
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...
Thank you all for any pointers and/or insight.for (@labsets) { if ($_ ~= /^lab\d{1}/) = [some condition] { print "$_ matched\n!" } else { print "print $_ did not match\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to compare elements within an array
by Kenosis (Priest) on Feb 20, 2014 at 19:03 UTC | |
by doubleqq (Acolyte) on Feb 20, 2014 at 20:11 UTC | |
by Kenosis (Priest) on Feb 20, 2014 at 20:25 UTC | |
Re: How to compare elements within an array
by davido (Cardinal) on Feb 20, 2014 at 19:43 UTC | |
Re: How to compare elements within an array
by kcott (Archbishop) on Feb 23, 2014 at 08:33 UTC |
Back to
Seekers of Perl Wisdom