Ok, if anyone is interested, here is my answer:

#!/usr/bin/perl -w

# Testing code for Exercise 6-1. Your task is to write the sub
# gather_mtime_between.

use strict;

use File::Find;
use Time::Local;

my ($start, $stop) = @_;
my @starting_directories = @_;
my @found_items;

sub gather_mtime_between {
        return (
                sub {
                        my $timestamp = (stat $_)[9];
                        if ($start <= $timestamp && $timestamp <= $stop){
                                push @found_items, $File::Find::name;
                        } else {
                                print "No file modified between $start and 
$stop in
$File::Find::dir\n";
                        }
                },
                sub { return @found_items }
                )
}

my $target_dow = 5;     # Sunday is 0, Monday is 1, ...
@starting_directories = ("/home/io/chris_perl/int_perl/");

my $seconds_per_day = 24 * 60 * 60;
my($sec, $min, $hour, $day, $mon, $yr, $dow) = localtime;
$start = timelocal(0, 0, 0, $day, $mon, $yr);   # midnight today
while ($dow != $target_dow) {
  # Back up one day
  $start -= $seconds_per_day;           # hope no DST! :-)
  if (--$dow < 0) {
    $dow += 7;
  }
}
$stop = $start + $seconds_per_day;

my($gather, $yield)  = gather_mtime_between($start, $stop);
find($gather, @starting_directories);
my @files = $yield->();

for my $file (@files) {
  my $mtime = (stat $file)[9];  # mtime via slice
  my $when = localtime $mtime;
  print "$when: $file\n";
}

I think my main problem was that I didn't grasp how File::Find works.
After I read the docs on CPAN, the solution came together.


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


Reply via email to