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

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.

Replies are listed 'Best First'.
Re^4: Help with ReadDir and Stat?
by batcater98 (Acolyte) on Mar 13, 2008 at 18:50 UTC
    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 }