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);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Recursive Directory Listings
by Zaxo (Archbishop) on Sep 06, 2005 at 15:47 UTC | |
by shagbark (Acolyte) on Nov 01, 2014 at 17:47 UTC | |
by jdporter (Paladin) on Nov 01, 2014 at 19:38 UTC | |
by Anonymous Monk on Nov 02, 2014 at 07:19 UTC | |
|
Re: Recursive Directory Listings
by japhy (Canon) on Sep 06, 2005 at 15:49 UTC | |
by ikegami (Patriarch) on Sep 06, 2005 at 17:18 UTC | |
|
Re: Recursive Directory Listings
by pbeckingham (Parson) on Sep 06, 2005 at 16:14 UTC | |
|
Re: Recursive Directory Listings
by sh1tn (Priest) on Sep 06, 2005 at 17:04 UTC | |
|
Re: Recursive Directory Listings
by sk (Curate) on Sep 06, 2005 at 15:47 UTC | |
|
Re: Recursive Directory Listings
by McDarren (Abbot) on Sep 07, 2005 at 10:05 UTC |