in reply to Re: Recursive sub
in thread Recursive sub

Your else clause is unnecessary, as it's not doing anything. There definitely will be stuff (in many directories) that don't meet the -f or -d tests. In that case, he will just fall through and the loop will continue with the next item.

------
We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: Re: Recursive sub
by Not_a_Number (Prior) on Sep 23, 2003 at 21:52 UTC

    You're right, of course. I originally had something like this:

    my @anomalies; sub recurseDir2 { my @temp = (glob $_[0]); foreach (@temp) { if (-d $_) { print "Directory: $_" , "\n" ; recurseDir2("$_/*"); } elsif (-f $_) { print "File: $_ \n"; } else { push @anomalies, $_; } } } print "Anomalies: @anomalies";

    but as I found no 'anomalies' in my filepaths I stupidly changed my code to what I posted. Thanks for pointing out my mistake.

    dave