I have ruby program that reads an error log txt file
This is a question I introduced on Saturday.I have anywhere from 1 to X number of error logs that are text files. It is to the point where it recognizes the error log. It is then suppose to read the file and find how many times the word WARNING is listed and how many times the word ERROR is listed. As I said it finds the file and does not give an error but it also reports WARNING = 0 and ERROR = 0.
I have pasted the code and the result when it is run below and I have attached the text file I have been using to test with.
# fill in the path of the input files here
my_path = "C:\\Ruby\\Text\\"
warning = 0
error = 0
d = Dir.new(my_path)
d.each do |fl|
unless fl == '.' or fl == '..' then
puts my_path + fl
File.open(my_path + fl, "r").each do |line|
if line =~ /error/ then
error += 1
elsif line =~ /warning/ then
warning += 1
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.