Re: $File::Find and no_chdir
- From: schms@xxxxxx (Schms)
- Date: Thu, 27 Sep 2007 11:42:20 -0700
On 27 Sep., 15:01, mri...@xxxxxxxxx (Paul Lalli) wrote:
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
Thanks Paul and John. So, I will try with
opendir DH, $DIR or die "Cannot open '$DIR' $!";
print map "$DIR/$_\n", readdir DH;
closedir DH;
.
- Follow-Ups:
- Re: $File::Find and no_chdir
- From: Dr.Ruud
- Re: $File::Find and no_chdir
- References:
- $File::Find and no_chdir
- From: Schms
- Re: $File::Find and no_chdir
- From: Paul Lalli
- $File::Find and no_chdir
- Prev by Date: Re: encoding problem?
- Next by Date: Re: Problem with repeating characters in regex
- Previous by thread: Re: $File::Find and no_chdir
- Next by thread: Re: $File::Find and no_chdir
- Index(es):