in reply to File::Find exit
See. the File::Find docs for more info.find({ wanted => \&foo, preprocess => sub { grep !/^d/i, @_ }, }, '/somedir');
Update: as tye has pointed out, the above doesn't really answer your question. Since File::Find wasn't designed to allow stopping mid-process, File::Find::Rule is probably a better option e.g
Or if you really want to stop iterating once you've seen the first file beginning with a 'd'use File::Find::Rule; my $seen = 1; my @files = find( file => exec => sub { $seen = 0 if /^d/i; $seen }, in => '/somedir' );
my @files; my $rule = rule(file => start => '/somedir'); while(my $file = $rule->match) { last if $file =~ /^d/i; push @files => $file; }
_________
broquaint
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: File::Find exit
by pg (Canon) on Oct 29, 2003 at 17:26 UTC |