in reply to Re: File Search
in thread File Search

Thanks for guidenance. I have it working in my test environment. However, I know in my production environment I will be encountering files and directories from previous process runs. I need to be able to only select those directories/Files that have been created on the current date, and if possible between a defined start and end time. Any suggestions? Thanks in Advance.

Replies are listed 'Best First'.
Re: Re: Re: File Search
by Beechbone (Friar) on Oct 27, 2003 at 13:18 UTC
    That's fairly easy. Just see perldoc -f stat. You can get all possible data about a file, including the last change timestamp.

    Please note, you cannot usually get the creation time, because it is not recorded by all file/operating systems.

    sub wanted { return unless /\.out$/; my $ctime = (stat $_)[9]; if ($ctime < time()-(2*60*60)) { print "$_ is older than 2 hours.\n"; } elsif ($ctime > time()) { print "$_ has used a time machine to get here!\n"; } else { un#link $_; print "I hate new files.\n"; } }

    Search, Ask, Know