From: Manuel Zabelt Date: 2001-05-24T07:11:23+09:00 Subject: [ruby-talk:15626] $& works -- md[0] does not Hello! The follwing snippet of code does not work: 08:File.open('/var/log/online') do |f| 09: f.each do |line| 10: md = /\d+\.\d+\.\d+\.\d+/.match line 11: ips[md[0]]+=1 if md[0] 12: end 13:end Error message: ./isdn.rb:11: undefined method `[]' for nil (NameError) from ./isdn.rb:9:in `each' from ./isdn.rb:9 from ./isdn.rb:8:in `open' from ./isdn.rb:8 BUT the follwing snippet of code DOES work: 08:File.open('/var/log/online') do |f| 09: f.each do |line| 10: md = /\d+\.\d+\.\d+\.\d+/.match line 11: ips[$&]+=1 if $& 12: end 13:end What am I doing wrong? Being about this for 60 minutes now, I get kind of frustrated slowly ... thanks for any help greetings manu