Re: $File::Find and no_chdir



On Sep 27, 6:00 am, sc...@xxxxxx (Schms) wrote:
I have a UNIX directory $DIR which contains a lot of files and
subdirecotires. Now, I would

like to list all files and subdirectories in $DIR only. That means,
$File::Find should not

go into any subdirectories of $DIR and list the files and
subdirectories there as well.

So far, I have not had any luck with the option no_chdir =>0.

That's because no_chdir has absolutely nothing to do with this issue.
no_chdir simply means that File::Find doesn't change the current
working directory as it recurses.

You want $File::Find::prune. Set it to 1 in your &wanted function any
time the directory is one you don't want to recurse into. See
File::Find's documentation for more info.

And more importantly, see John's reply - if you don't want to recurse,
you shouldn't be using File::Find to begin with. Just get a directory
listing.

Paul Lalli

.



Relevant Pages