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