Ok, so I chdir. The deal is that the subdir is based on
the script looking at the most recent subdir.
Next month the "FEB 2009/Results %m-%d-%y" subdirs
will be created under "RESULTS 2009". Now there will
be "JAN 2009" and "FEB 2009" subdirs with
"Results %m-%d-%y" subdirs.

#!/usr/bin/perl use warnings; use strict; use File::stat; use Time::localtime; use File::Copy; use File::Find; use POSIX qw(strftime); #=for my $tm = localtime; my $YEAR= $tm->year+1900; my $MONTH = $tm->mon; #my $subdir = strftime "Results %m-%d-%y", localtime; #my $YEAR=year+1900; #my $MONTH = #my $YR_RESULT_dir = strftime "RESULTS $YEAR", localtime; my $Month_YR_dir = strftime "$MONTH $YEAR", localtime; my $newdir = '/home/mgavi/testdir1/$Month_YR_dir/'; print "$monthyr"; my $root='/home/mgavi/testdir1'; my $seqdir = "/home/mgavi/testdir2/SeqAssembly"; print "$YEAR $MONTH $root\n"; opendir (my $dh, $root); chdir($newdir); # the new subdir to search my @files=readdir $dh; for my $f (@files){ my $mod_time=-M $monthyr."/".$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($newdir."/".$f)->mtime),"\ +n"; copy("$f","$seqdir"); } closedir $dh;

I get

Usage: POSIX::strftime(fmt, sec, min, hour, mday, mon, year, wday = -1, yday = -1, isdst = -1) at dirtt.pl line 20.
when I run the script


In reply to Re^2: Dynamically searching subdirs with titles based on year,month, and date by lomSpace
in thread Dynamically searching subdirs with titles based on year,month, and date by lomSpace

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.