#!/usr/bin/env ruby

require 'cgi'

print "Content-Type: text/html\n\n<body>"

def fileinfo( file)
	lines = '<table border>'
	%w!original_filename local_path read content_type!.each { |m|
		lines << "<tr><td>#{m}</td><td>#{file.send(m)}</td></tr>"
	}
	lines << '</table>'
end

begin
	cgi = CGI.new( "html3" )
	print '<h1>result</h1>'
	print fileinfo( cgi.params['file1'][0]) + '<hr>'
	print fileinfo( cgi.params['file2'][0]) + '<hr>'
	print '<table border>'
	%w!text1 text2 checkbox1 radio1 radio2 textarea1 textarea2 select1 select2!.each { |k|
		print "<tr><td>#{k}</td><td>#{cgi.params[k][0].read}</td></tr>"
	}
	print '</table>'
rescue Exception
	print 'error:'
	print $!.to_s
end
