Does anyone have example code that loops through a directory of files and prints a list of those created within a user selected date range.

Here's what I've got so far, but it doesn't get the date the file was created and I can't seem to find out how to do that:

Kindest Regards,

Bill Stephenson

<code>

#!/usr/bin/perl -Tw

# We use these fine modules...
use strict;

my $directory = "bilbo";

my $path="/Library/WebServer/CGI-Executables/ezLite/users/";

&search_by_date;
######################################################################## #
######################################################################## #
# Sub search_by_date
######################################################################## #
sub search_by_date {


my $atime;
my $mtime;
my $ctime;
my $file;
my $file_stat= "$path$directory";

opendir(DIR, "$file_stat") or die "can't opendir $file_stat: $!";

        while (defined($file = readdir(DIR))) {
        
        my ($file_name, $ext) = split(/\./, $file);
        
                if ($file_name) {
                
                        if ($ext) {
                                
                                if ($ext eq "dat") {

($atime, $mtime, $ctime) = (stat("$file_stat/$file"))[8,9,10];

print "File Name : $file\n";
print "Last Read : $atime\n";
print "Last Changed: $mtime\n";
print "Created On : $ctime\n";
print "\n\n";

# sort by date range here
# or open and report on each file.

}

}

}

} # end while loop


        closedir(DIR);

}

</code>


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to