I need to do the following:
1. opendir
2. Check folder name for current month year.
a. If not current skip.
b. If current then opendir.
3. Check the first file's name in the dir
a. If 1st file's name does not contain, one of four regex's.
then skip.
b. Else read file names.
c. Iterate through the files and parse out the id #.
d. create a hash with the file name and parsed id# to match files with the same id# that occur exactly four times.
e. save those that meet criteria of step 3d. Possibly in a glob.
4. chdir
5. mv data from step 3e to working dir. Next do:
a. create another hash to match id# from step 3c with subdir names in working dir.
b. Upon match of subdir open it and mkdir with id#_sa.
c. Deposit the moved files that have same id# as subdir name into the newly created dir id#_sa.(id#_sa ex. 12335_sa)
Here is my code:
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Copy;
opendir( RS, "seqresults/resultsdate");
my %rs;
while (defined($rs = readdir (RS)))
{
@rs_info = split(/_/,$rs);
my $idnum= $fields[0];
if ($count == null){
${maid}=1;
}else{
${maid}=$count+1;
}
foreach my $maid ( keys %h ){
if ($h{$maid}==4){
#call routine to do your copy logic
}
}
}
closedir RS;
opendir( SA, "/newdir/");
# This is what i have thus far. Need help!