-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Je Merkredo 23 Majo 2001 15:11, vi skribis: > 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 ... > 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 If there is no match, md (and $&) will be nil... but you're trying to do an array access (md[0]) on nil in the first case, whereas you aren't in the second case. === SER Deutsch|Esperanto|Francaise|Linux|Java|Ruby|Aikido|Dirigibles|GPG === http://www.germane-software.com/~ser jabber.com:ser ICQ:83578737 Computers let you make More mistakes faster than any other invention in human history, with the possible exception of handguns and tequila. -- Mitch Radcliffe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.2 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE7DDmdP0KxygnleI8RAoTwAJ9ylZ9ouBVDSACRDXGLfYexFyTHvwCfZKAC 3j5ME52CM4CR5ivjRg6NFDg= =EXmG -----END PGP SIGNATURE-----