#excert from tachyon's code at http://www.perlmonks.org/?node_id=157851 my @dirs = ($root); for my $path (@dirs){ opendir ( DIR, $path ) or next; # skip dirs we can't read while (my $file = readdir DIR) { next if $file eq '.' or $file eq '..'; # skip dot files if ( -d $path.$file ) { push @dirs, $path.$file.'/'; # add dir to list } } closedir DIR; }