Ok I will get straight to the code causing the problem, so first off you need to no that 'eventdateID' is an array full of values taken from log files. A sample of the values in this array are: > MonFeb0220091 > MonFeb0220091 > MonFeb0220091 > MonFeb0220091 > MonFeb0220091 > MonFeb0220091 > WedAug062008 > WedAug062008 Then I have the following code: >> counts = Hash.new(0) >> eventdateID.each {|d| counts[d] +=1} >> counts.each do |d,cnt| >> @alerts.push("#{event.event_id} #{@tab} #{event.time_written} >> #{@tab}#{event.event_type} #{@tab} #{type}") if cnt >= 5 >> end The @alerts.push data is again specific to the logs I am parsing. Basically each record in the log is given an ID number based on the time and date values which goes into eventdateID. The purpose of the code above is to check if any of the ID numbers occur more than 5 times in eventdateID. counts = Hash.new(0) - empty hash called counts eventdateID.each {|d| counts[d] +=1} - process each ID value in eventdateID and load into the hash counts counts.each do |d,cnt| - process counts and see how many of each ID value exist @alerts.push ............. if cnt >=5 - If there are more than 5 of an ID push some of the log data to an array which matches the eventdateID I have done some checking eventdateID.each {|d| counts[d] +=1} @alerts.push gives MonFeb0220091 MonFeb0220091 MonFeb0220091 MonFeb0220091 MonFeb0220091 MonFeb0220091 WedAug062008 WedAug062008 At this stage we are on the right lines we have the hash counts with some date ID's in it. Another test was: eventdateID.each {|d| counts[d] +=1} counts.each do |d,cnt| @alerts.push cnt This gives 1 1 1 1 1 1 1 This is where the problem I want it to identify that MonFeb0220091 occurs 6 times in the counts hash WedAug062008 occurs twice in the counts hash As a result of this I am expecting my code to output the log data to the @alerts array based on the eventdateID MonFeb0220091 as it occurs more than 5 times. Below is my code again to summarise, but the restriction is you do not have the logs, I can assure you the data in eventdateID are values like this MonFeb0220091. Code block: eventdateID.push eventsbydate.gsub(/\s/, '')[0..7] + eventsbydate[26..30] counts = Hash.new(0) eventdateID.each {|d| counts[d] +=1} counts.each do |d,cnt| @alerts.push("#{event.event_id} #{@tab} #{event.time_written} #{@tab}#{event.event_type} #{@tab} #{type}") if cnt >= 5 end Thanks again. Robert Klemme wrote: > 2009/2/3 Stuart Clarke <stuart.clarke1986 / gmail.com>: >> Thanks for replying and sorry for the confusion. >> >> My hash (counts) contains date and time ID's like so TueAug052008 > > Obviously not as the output below demonstrates that there is just a > single entry in the Hash. > >> When I do a puts on counts I get a list of these as per there date and >> time values which is what I want. However counting to see if there is >> more than 5 occurances of one the ID values fails and doesn't find >> anything in my data set. >> >> I have done as you asked and the output is as follows: >> >> {"WedAug062008"=>1} > > Looks like there is a lot missing. > >> This suggests there is a problem. Just for your information doing an >> output on counts (the hash) gives this: > > What does "doing an output" mean? Please be more specific (e.g. by > posting complete code, ideally a test case that someone else can > execute), otherwise nobody can help you. > >> MonFeb0220091 >> MonFeb0220091 >> MonFeb0220091 >> MonFeb0220091 >> MonFeb0220091 >> MonFeb0220091 >> MonFeb0220091 >> MonFeb0220091 >> WedAug062008 >> WedAug062008 > > Cheers > > robert -- Posted via http://www.ruby-forum.com/.