in reply to Re^4: Dynamically searching subdirs with titles based on year,month, and date
in thread Dynamically searching subdirs with titles based on year,month, and date
when used in:use strict; use warnings; use POSIX qw(strftime); my ($m, $y) = strftime ("%b %Y", localtime) =~ m|(\S+)\s(\S+)|; print "$m $y";
#!/usr/bin/perl use strict; use warnings; use POSIX qw(strftime); my $Results = strftime ("Results %m-%d-%y", localtime) =~ m|(\S+)\s(\S ++)|; print "$Results\n"; #my ($m, $y) = strftime ("%b %Y", localtime) =~ m|(\S+)\s(\S+)|; #print "$m $y\n"; my $root='/home/mgavi/testdir1'; my $seqdir = "/home/mgavi/testdir2/SeqAssembly"; opendir (my $dh, $root); #chdir($newdir); my @files=readdir $dh; for my $f (@files){ my $mod_time=-M $root."/".$f; #skip unless modification date is less than one day ago next if $f eq '.' || $f eq '..' || $mod_time > 1.0; print $f,"\t",$mod_time,"\t",ctime(stat($root."/".$f)->mtime),"\n" +; copy("$f","$seqdir"); } closedir $dh;
1
I am looking for "Results 01-16-9-09A" to be returned because
that is the most recent dir in "JAN 2009" directory.
|
|---|