On Oct 30, 2007, at 2:41 PM, Robert Keller wrote:

>
> Below is part of a big loop that goes through each found line for  
> each document, and is in its own method.
>
> case  top_event[0].lstrip.rstrip
>     when "Redo size:"
>
>             $redo_cnt[0] += 1
>             $redo_cnt[1] += top_event[1].to_f
>
>
>
>     when "Logical reads:"
>
>             $log_read_cnt[0] += 1
>             $log_read_cnt[1] += top_event[1].to_f
>

count = Hash.new{|h,k| h.update k => Hash.new{|h,k| h.update k => 0}}

case top_event[0].strip
   when /redo size:/i
     count[:redo][0] += 1
     count[:redo][1] += Float(top_event[1])

   when /logical reads:/i
     count[:read][0] += 1
     count[:read][1] += 1

...

require 'yaml'

y count


is one approach.

cheers.

a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being  
better. simply reflect on that.
h.h. the 14th dalai lama