From:                   Chris <[EMAIL PROTECTED]>
> 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 }
>               )
> }


If you do it this way there is no point in returning the subroutine 
references in the first place. You are using global variables here 
(even though you declare them with my).

You can't call the gather_mtime_between() twice and get two unrelated 
pairs of functions. You should move the declarations INTO the sub 
gather_mtime_between(). And fix the assignment from @_.

The exercise is a bit awkward though.

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


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


Reply via email to