On 04/28/2012 22:05, Sat Guru Khalsa wrote:
>> But this did not work for recursion>> sub recurseDir () {> my ($dir) = @_;> opendir (DIR, $dir);> while (defined (my $f=readder(DIR))) {> if (-d "$dir\\$f") {&recurseDir("$dir\\$f"); }> .. other wise do something with the plain file ..
It works OK to just use DIR if you slurp the dir contents into a
vrbl (don't have a memory issue):
sub recurseDir () {
my $dir = shift;
opendir (DIR, $dir) or die ...;
my @files = readdir $dir;
closedir DIR;
foreach my $file (@files) {
next if $file =~ /^\.\.?$/;
if (-d "$dir/$file") {
recurseDir ("$dir/$file");
} else {
# otherwise do something with the plain file ..
}
}
}
_______________________________________________
PDK mailing list
P...@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs