From: Pablo Lorenzzoni Date: 2002-06-22T19:41:13+09:00 Subject: Re: What do you think of this idiom? Hello! I like it, but it's not going to work. File.stat needs the the directory to exist. First you have to test that: begin print "Dir = " mydir = gets.chomp dir = Root + mydir raise "No such directory" if not File.exist?(dir) # added raise "It's not a directory" if not File.stat(dir).directory? # changed rescue => err puts err retry end []s Pablo Em Sab 22 Jun 2002 01:20, Hal E. Fulton escreveu: | I was writing a little script which prompted | the user for a directory. I wanted to repeat | until a valid directory was entered. | | At first I was going to write an actual loop. | Then I thought of this little technique. What | do you think? How would you do it? | | Cheers, | Hal Fulton | | | begin | print "Dir = " | mydir = gets.chomp | dir = Root + mydir | raise "No such directory" if not File.stat(dir).directory? | rescue => err | puts err | retry | end -- Pablo Lorenzzoni (Spectra) GnuPG Key ID 268A084D at search.keyserver.net Webpage: http://people.debian.org/~spectra/