http://www.perlmonks.org?node_id=489552

curtisb has asked for the wisdom of the Perl Monks concerning the following question:

All,

I'm trying to write my own directory search function. I'm using File::stat module to help determine is the file is a directory or a single file.

However, the script runs but does not look into the directories as it finds one. Can someone please let me what I'm doing wrong.

I know that there are other ways of doing this, like the finddepth function or the built in stat() function but I
want to do it this way because I'm doing to be doing some text subbing as it goes.

Any help will be appreciated

Thanks,
Bobby Curtis

#!D:/Programs/PERL/bin/perl.exe -w use File::stat; my $dir = "D:/"; opendir(DIR, $dir) or die $!; while(defined (my $file = readdir(DIR))) { print "$file\n"; if(-d "$file") { print "directory found....\n"; opendir(newDIR, $file) or die $!; while(defined ($file = readdir(newDIR))) { print "got new file!!!!\n"; print "$file\n"; } closedir(newDIR); } } closedir(DIR);