Hello,

On 15 Ԧ 2011, at 6:06 .., Robert Klemme wrote:

> On Mon, Aug 15, 2011 at 12:48 AM, Panagiotis Atmatzidis
> <ml / convalesco.org> wrote:
>> Hello,
>> 
>> On 14 Ԧ 2011, at 10:22 .., 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 to 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})/
> =~ line
>    puts "id: #$2 | date: #$1 | IP: #$3"
>  end
> end
> 
> Kind regards
> 
> robert
> 
> -- 
> remember.guy do |as, often| as.you_can - without end
> http://blog.rubybestpractices.com/
> 

Thanks for the pointers Robert! I'll do some checks and probably implement your solution which seems more appropriate,

Best Regards

--
Panagiotis Atmatzidis

personal: atma / convalesco.org
lists: ml / convalesco.org
blog: http://www.convalesco.org

The wise man said: "Never argue with an idiot. They bring you down to their level and beat you with experience."