From: Joseph McDonald Date: 2001-09-21T03:34:49+09:00 Subject: [ruby-talk:21452] Re: newbie help dsc> x = 0 dsc> badips = Hash.new(0) dsc> while line = gets dsc> if line =~ /.ext|winnt|msadc|scripts/i dsc> line =~ /client ([^\]].*)]/ dsc> bad = $1 dsc> bad.gsub!(/[^0-9\.]/, "") dsc> if not badips.has_key?(bad) dsc> $stdout.puts "#{bad}" dsc> end dsc> badips[$1] += 1 dsc> x += 1 dsc> end dsc> end dsc> ------------------- dsc> It seemed to me that badips is a hash of the form ipadr::count but I could not dsc> print it There is a bug in the above (sorry). change badips[$1] += 1 to: badips[bad] += 1 Then you can do something like: badips.each do |k, v| puts "#{v}\t#{k}" end regards, -joe