in reply to Re: How to conditionally terminate finddepth?
in thread How to conditionally terminate finddepth?

Nice, but I'd be wary of missing some other important die in there, (say, a directory read error, or something equally dire) so would do:
my $newfile = undef; eval { finddepth( sub {if (-M $_ <= 30) {$newfile=$File::Find::name; die "";}}, $base); }; die "$@" if ($@ and !defined($newfile)); if (defined($newfile)) {print "$base has something new in it\n";} else {print "$base is just old stuff\n";}
--
@/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/

Replies are listed 'Best First'.
Re^3: How to conditionally terminate finddepth?
by PodMaster (Abbot) on Sep 13, 2005 at 20:20 UTC
    Or you could forgo eval/die and use goto
    my $newfile = undef; finddepth( sub { if (-M $_ <= 30){ $newfile=$File::Find::name; goto done_finddepth; } }, $base ); done_finddepth: die "the new file is $newfile";
    I once suggested an official breakout function to the perl5-porter, to be used like
    my $count = 0; &find( sub { $count++; File::Find::breakout() if $count == 500; }, '/');
    but nothing came of it. File::Find's way of doing things can mess with your head.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.