koti688 has asked for the wisdom of the Perl Monks concerning the following question:
print "Enter The Directory Path"; $dir = <STDIN>; chomp($dir); opendir(DIR, $dir) || die "Unable to open the directory"; @contents=readdir(DIR); foreach $listitem ( @contents ) { if ( -d $listitem ) { opendir(DIR,$listitem) @c2=readdir(DIR); foreach $l2(@c2) { if (-d $l2) { print $l2; print " It's a directory!\n"; } else { print $l2; print " It's a file!\n"; } } } print $listitem; print " It's a directory!\n"; } else { print $listitem; print " It's a file!\n"; } } close(DIR);
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Reading Files Across Directories and Sub Directories
by dHarry (Abbot) on Dec 02, 2008 at 11:07 UTC | |
| |
Re: Reading Files Across Directories and Sub Directories
by cdarke (Prior) on Dec 02, 2008 at 12:13 UTC | |
by Fletch (Bishop) on Dec 02, 2008 at 17:41 UTC | |
by ikegami (Patriarch) on Dec 03, 2008 at 07:38 UTC | |
by koti688 (Sexton) on Dec 03, 2008 at 07:24 UTC | |
by Anonymous Monk on Apr 26, 2017 at 13:40 UTC | |
Re: Reading Files Across Directories and Sub Directories
by vrk (Chaplain) on Apr 26, 2017 at 14:58 UTC |