From: David Douthitt Date: 2000-03-16T17:45:06-06:00 Subject: [ruby-talk:01936] BUG??? [..... I received this output today......] # ./others.rb sys1 sys2 sys3 sys4 sys5 sys6 | less ./others.rb:29: [BUG] obj_free() called for broken object Mar 12 17:19:36 172.16.17.31 printer: offline or intervention needed Mar 12 17:19:36 172.16.17.31 printer: paper out Mar 12 17:20:10 172.16.17.31 printer: error cleared Mar 12 18:31:10 172.16.17.31 printer: toner/ink low Abort # [..... this output was generated when I ran this script .....] #!/usr/bin/ruby # Interesting problem reached here... # # ARGV is [ "arg1", "arg2", "arg3" ] # results from a scan are [ [ "str1" ] ] # # Thus, ARGV.each is "arg1" ... "arg2" ... "arg3" ... # scanXX.each is [ "str1" ] ... [ "str2 ] ... # # Thus ARGV[0] is "arg1" ; scanXX[0] is [ "str1" ] ; # and scanXX[0][0] is "str1" # # This explains a lot. systems = Array.new class String def systemName self.scan("^... .. ..:..:.. ([^ ]*)") end end File.open("/var/log/messages").each { |line| line.chomp! # sys = line.scan("^... .. ..:..:.. ([^ ]*)") sys = line.systemName systems = systems | sys if not ARGV.include?(sys[0][0]) print(" ", line, "\n") end } # (systems.sort!).each { |sys| # print(" ", sys, "\n") # } [....snip!.......] Note my comment about ARGV[0] and scan().each[0][0] (!)