Ok, here's what you want Daniel;

def meth
    str =<<-"ENDSTR"
       alias :rand_old :rand
       @@rand_call_count = 0
       def rand
          @@rand_call_count += 1
          puts @@rand_call_count
          rand_old
       end
    ENDSTR
    Kernel.module_eval( str )
    rand
    rand
    rand
    rand
    Kernel.module_eval( "alias :rand :rand_old" )
    Kernel.module_eval( "remove_method( :rand_old ) " )
end

meth

This will still allow rand to return the correct value, and it will get 
count for you.

This is a cleaner solution then before.

HTH,

Zach