Can anybody suggest where i am wrong to check the files older than three days. I am using the below code. Find the files details below and modified time of the files details also.
use strict; use warnings; my $today = time; my @rootfolders=("d:/temp/"); for my $folder (@rootfolders) { $folder=~s/\\/\//g; $folder=$folder."/"; $folder=~s/([\/]+)$/\//; opendir(DIR,"$folder"); for my $temp (readdir(DIR)) { if (!(($temp eq ".") || ($temp eq ".."))) { print "$folder$temp"; my $temp1=$folder.$temp; my $mtime = (stat "$temp1") [9]; my ($sec,$min,$hour,$day,$month,$year) = localtime($mtime); $month++; print " $month/$day/$year $hour:$min "; #I am trying to find here 12:00 AM in the morning time.so the files sh +ould be exactly three days back. ($sec,$min,$hour,$day,$month,$year) = localtime($today); if ($hour > 1) { $hour=$hour*60*60; } my $findtime=$sec+$min+$hour; $today=$today-$findtime; my $older=(60*60*24)*3; $today=$today-$older; ($sec,$min,$hour,$day,$month,$year) = localtime($today); $month++; if ($today > $mtime) { print " OLDER 3 days"; } if (-d $temp1) { print " is a folder\n"; } else { print " is a FILE\n"; } } } close(DIR); }
d:/temp/BBDPS0478M_ITR.pdf 7/30/109 17:13 OLDER 3 days is a FILE d:/temp/Binder1.pdf 6/12/109 19:20 OLDER 3 days is a FILE d:/temp/bri.doc 8/1/109 15:32 is a FILE d:/temp/Can be delete.xls 2/18/109 16:4 OLDER 3 days is a FILE d:/temp/doc 8/3/109 15:52 is a folder d:/temp/Docx 8/3/109 15:52 is a folder d:/temp/ps 8/3/109 15:52 is a folder d:/temp/screenshot.bmp 7/31/109 17:51 is a FILE

In reply to older files by Selvakumar

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.