pt = {} for file in ARGV case file when /(\d+)\/4\.2\.(\d+)\.(\d+)\.table$/ then ver, disci, categ = $1.to_i, $2.to_i, $3.to_i else next end File.open(file, 'r') {|fp| for line in fp case line.chomp when /^$/, /^\s*#/ then next when /^\s*\(-\)$/ then next when /^\s*(\d+)\s+(\d+)\s+/ then param = $1.to_i text = $' pid = format('%03u-%03u-%03u', disci, categ, param) vid = format('master-v%03u', ver) pt[pid] = {} unless pt.include?(pid) pt[pid][vid] = text else STDERR.puts "Error: bad line <#{line.chomp}>" end end } end for pid in pt.keys.sort vt = pt[pid] if vt.values.uniq.size > 1 then puts pid for vid in vt.keys.sort puts [vid, vt[vid]].inspect end end end