in reply to Re: Help with ReadDir and Stat?
in thread Help with ReadDir and Stat?

Thanks, this is a huge help - in relation to the "Date" comparison - get the mod time back using the stat and that works great, but how would I do the comparison to if the file was modified or created on "Today's" date? I.E. if the file was created/modified today I want to keeps it's info - if not I will move on? Having troubles figuring out how to get to teh "Day" comparison. Thanks Again, Ad.

Replies are listed 'Best First'.
Re^3: Help with ReadDir and Stat?
by Akoya (Scribe) on Mar 13, 2008 at 17:36 UTC
    You can pass the mtime to localtime. i.e.,
    my ($mday, $mon, $year) = localtime($mtime)[3,4,5];
    Then do the same with the current time:
    my ($cmday, $cmon, $cyear) = localtime(time)[3,4,5];
    and then compare them. I'm sure there's a more efficient way, but this should work.
      You have been a great help - I am learning a lot here. One more question. I am working on the date compare and I am getting errors. Here is what I am trying.
      my $lctime = strftime("%m_%d_%y",localtime); my $fltime = strftime("%m_%d_$y",localtime(stat($filename)[9])); if ($lctime = $fltime) { # processs file data }
      The Localtime(mtime) returned from the stat function is giving an error. Ideas on this? Thanks, Ad.
        localtime returns a list. You need indexes 3, 4, and 5 from that list. You're code can be modified like this:
        my $lctime = strftime("%m_%d_%y",localtime[3 .. 5]); my $fltime = strftime("%m_%d_$y",localtime(stat($filename)[9])[3 .. 5] +); if ($lctime = $fltime) { # processs file data }