Re: $File::Find and no_chdir



schms wrote:
Hi,

Hello,

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.

find ( {
no_chdir => 0,
wanted => sub {
print "$File::Find::name\n" ;
}
},
$DIR
);

It sounds like you don't need to use File::Find at all:

opendir DH, $DIR or die "Cannot open '$DIR' $!";
print map "$DIR/$_\n", readdir DH;
closedir DH;



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.