in reply to Re: Recursive Directory Listings
in thread Recursive Directory Listings

To get indefinite depth, you'll need a recursive solution

Not quite. You simply need a stack. Recursion is just one way of obtaining a stack. What follows is another:

my @to_visit = $base_dir; while (@to_visit) { my $dir = pop(@to_visit); opendir(my $dh, $dir) or ...; my $file; while(defined($file = readdir($dh))) { next if $file eq '.'; next if $file eq '..'; # Should use File::Spec. $file = "$dir/$file"; if (-d $file) { push(@to_visit, $file); } else { ... } } }

Substitute pop with shift if you want to process the tree breadth first.