On Mon, Aug 15, 2011 at 12:48 AM, Panagiotis Atmatzidis
<ml / convalesco.org> wrote:
> Hello,
>
> On 14 =C1=F5=E3 2011, at 10:22 =EC.=EC., Gunther Diemant wrote:
>
>> I would say, you should only call
>> x.readlog
>> and not
>> puts x.readlog
>>
>> You call put in the method which gives you the desired output. The 'raw'
>> output is the return value of the readlog method, which you don't want t=
o be
>> printed.
>
> I had the feeling that it was something that obvious that I'm missing but=
 I focused so much on the function that I missed it!

A few more remarks: since those files can be large a better choice is
usually to use File.foreach.  You can also shorten your regexp a bit
by using non capturing groups with repetition markers.

Example (untested):

File.foreach @logfile do |line|
  if /^(\d{4}(?:-\d\d){2}).*?(\d{2}(?::\d{2}){2},\d{3}).*?(Ban).*?(\d{1,3}(=
?:\.\d{1,3}){3})/
=3D~ line
    puts "id: #$2 | date: #$1 | IP: #$3"
  end
end

Kind regards

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/