# ungetestet use File::Find; my @dirs; find(\&wanted,"C:\\"); my $file = '/path/to/file'; open my $fh, '>', $file or die $!; print $_,"\n" for @dirs; close $fh; sub wanted{ push @dirs,$File::Find::name if -d $File::Find::name; }