in reply to listing all subdirectories of directory into file

Take a look at File::Find and the -d function in perlfunc