#!/usr/local/bin/ruby teams = Array.new IO.foreach("vote.tbl") do |x| sname, gname = x.scan(/(\w+)\s+(.*)/)[0] next unless sname && gname teams[teams.length] = sname end point = {} for t in teams point[t] = 0 end Dir.foreach(".") {|dir| next unless test(?d, dir) next if /^\./ =~ dir # dir is the same as users login name Dir.foreach(dir){|pt| next if /^\./ =~ pt file = "#{dir}/#{pt}" next unless test(?f, file) team = open(file, "r").gets.chomp! if point.has_key?(team) then point[team] += pt.to_i end } } puts '' for t in point.keys.sort{|x, y| point[y] <=> point[x]} print " \n \n", t, t, point[t]) pt = point[t] print " \n" end puts '
" printf("%s (%3d)\n " printf '%d', pt, pt puts "
'