From: Sebastian Hungerecker Date: 2007-11-16T17:11:58+09:00 Subject: Re: Recursion help. JeremyWoertink@gmail.com wrote: > I tried your version of the program. It seems to go into an endless > loop, or just takes a REALLY long time. I stopped it after 30 > seconds. As I said, I didn't test the code, but I really can't see where it would go into an endless loop. I only have each-loops in there. If you give me a sample input file and a specification how the resulting output file should look like I could go and debug. > So, I see why you would use "w" and not "w+", but why do you use the > ARGV[0] ||? As I said, I prefer command line arguments to reading from STDIN. ARGV[0]||ask_for takes the first command line argument or, if there was no first command line argument, asks the user for input. > I know that ARGV is an array, but I don't know what it is used for Command line arguments. > or > why you would use it instead of making your own array. Your own array would only contain elements you put in it. ARGV contains the command line arguments. > Also, why would > you assign the filename the user input *or* ARGV[0]? So the script doesn't ask for user input if the filename was already specified as a command line argument. > The thing with the each_with_index is that the second record will have > a sequence of 2, and it should have a sequence of 1. Your sequence variable started at 1, too, and was incremented by 1 at every iteration. The each_with_index with sequence+1 should behave exactly like that. HTH, Sebastian -- Jabber: sepp2k@jabber.org ICQ: 205544826