D
Derek Smith
How can I use a while loop in such as way where I want to process the
file until EOF? thank you!
Here is my code:
mailog="/tmp/maillog"
last_record="Jul 15 22:09:10"
File.open(mailog, 'r+').each { |line|
while !mailog.eof?
if line =~ /^#{last_record}/o
p line
end
end
}
mail.scr:6: undefined method `eof?' for "/tmp/maillog":String
(NoMethodError)
from mail.scr:5:in `each'
from mail.scr:5
file until EOF? thank you!
Here is my code:
mailog="/tmp/maillog"
last_record="Jul 15 22:09:10"
File.open(mailog, 'r+').each { |line|
while !mailog.eof?
if line =~ /^#{last_record}/o
p line
end
end
}
mail.scr:6: undefined method `eof?' for "/tmp/maillog":String
(NoMethodError)
from mail.scr:5:in `each'
from mail.scr:5