On Wed, Mar 26, 2003 at 05:50:47AM +0900, Krishna Dole wrote: > def list_dirs( inDir ) > Dir.foreach( inDir ) {|x| > print( x ) > if File.ftype( x ) == "directory" > list_dirs( x ) > end > } > end > > ARGV.each{ |dirName| > list_dirs(dirName) > } Dir.foreach lists "." (current directory" and ".." (parent directory) which is why you are getting infinite recursion. Try adding: next if x == "." or x == ".." To make your program work you will also need to chdir() into each directory, or else build up a pathname, so that directories within directories are found. Something like this: path = inDir + "/" + x if File.ftype( path ) == "directory" list_dirs( path ) end Regards, Brian.