From: Li Chen Date: 2008-07-21T22:25:53+09:00 Subject: Re: Where should I put the loops reuben doetsch wrote: > What you can do is write three loops so > > [A..Z].each do |letter| > [1...num].each do |number| > #Process the website in here > process_website letter number > end > end Hi Reuben, Thank you very much for the neat script. I have another question: within the nested loop the maximum num is not fixed, for example, there are A001-A201 for letter A and B001-B333 for letter B.... And most of the time I don't know what is the maximum page I can fetch for each letter. But I know if the page doesn't exit that Ruby will fetch the same papge again and again until it comes to the upper limit of loop. In order to break out of the loop what I do is that I compare the website address of current page and the previous page. If they are the same I am going to break out the current loop and go to next letter. I wonder how you implement this idea into the current script. Thanks, Li -- Posted via http://www.ruby-forum.com/.