From: cremes.devlist@... Date: 2006-06-05T23:51:36+09:00 Subject: Re: Directory.entries problems with while loops On Jun 5, 2006, at 9:33 AM, Tait Pollard wrote: > unknown wrote: >> On Jun 5, 2006, at 8:57 AM, Tait Pollard wrote: >> Show us some code and then we can help. >> >> cr > > here is the code > > c=File.dirname("directory.rb") > direc=Dir.entries(c) > b= Regexp.new(/tlb/) > counter,counter1=0,0 > array=[] > while(counter if (direc[counter]=~b) > puts direc[counter] > array[counter1]=direc[counter] > counter=+1 > end > counter=+1 > end The flaw is here: counter=+1 You are setting counter equal to +1 when you mean to increment it. Try: counter += 1 # notice the + is to the left of the = Also, you are never incrementing counter1, so perhaps the code should look like this: c=File.dirname("directory.rb") direc=Dir.entries(c) b= Regexp.new(/tlb/) counter,counter1=0,0 array=[] while(counter