From: doug@... Date: 2001-09-21T03:18:15+09:00 Subject: [ruby-talk:21451] newbie help If this is not the place to ask such questions, let me know. After pondering the book and a couple of website sites I could not write the following in ruby. Maybe someone could give me a jump start. Anyway thanks for any suggestions ------------------ open (IPADRS,"badip.list") || die "Error opening IP address list"; while () { chop; ++$badips{$_}; } close(IPADRS); while ( ($ip,$count) = each %badips) { print " $count $ip\n"; } ------------------ I started with a script (which works) ------------------ x = 0 badips = Hash.new(0) while line = gets if line =~ /.ext|winnt|msadc|scripts/i line =~ /client ([^\]].*)]/ bad = $1 bad.gsub!(/[^0-9\.]/, "") if not badips.has_key?(bad) $stdout.puts "#{bad}" end badips[$1] += 1 x += 1 end end ------------------- It seemed to me that badips is a hash of the form ipadr::count but I could not print it _____ Douglas Denault doug@safeport.com Voice: 301-469-8766 Fax: 301-469-0601