cgi引数解釈

 #!/usr/bin/ruby -Ke
 require 'cgi'
 require 'nkf'
 def main()
   print "content-type: text/plain\n\n"
   cgi=CGI.new
   wikihome='/wiki/'
 
   name=CGI::unescape(cgi.path_info.sub(wikihome,''))
 
   timestamp=CGI::unescape(cgi['t'].to_s)
   mode=CGI::unescape(cgi['m'].to_s)
   content=CGI::unescape(cgi['c'].to_s)
   speaker=CGI::unescape(cgi['s'].to_s)
   topic=CGI::unescape(cgi['o'].to_s)
   submit=(cgi.has_key?('u') ? true : false)
 
   puts " ページ名 : #{name}"
   puts " モード : #{mode}"
   puts " 内容 : #{content}"
   puts " 発言者 : #{speaker}"
   puts " 議題 : #{topic}"
   puts " 送信 : #{submit}"
 
 end
 main

メイン

 #!/usr/bin/ruby -Ke
 require 'cgi'
 require 'nkf'
 require './wikipage.rb'
 require './xhtmlparser.rb'
 def main()
   debug=false
   cgi=CGI.new
   wikihome='/wiki/'
   footnum=1,footnote=[],caption=[],capnum=[1]*10,level=0
 
   if cgi.path_info != "" && cgi.path_info != nil
     name=cgi.path_info.sub(wikihome,'')
   else
     name="%C4%A3OA%A5%B5%A1%BC%A5%D0"
   end
   mode=CGI::unescape(cgi['m'].to_s)
   mode='view' if mode==''
   timestamp=CGI::unescape(cgi['t'].to_s)
   content=CGI::unescape(cgi['c'].to_s)
   speaker=CGI::unescape(cgi['s'].to_s)
   topic=CGI::unescape(cgi['o'].to_s)
   submit=(cgi.has_key?('u') ? true : false)
 
   if debug
     print "content-type: text/plain\n\n"
     puts " ページ名(元文字列) : #{name}"
     puts " ページ名 : #{CGI::unescape(name)}"
     puts " モード : #{mode}"
     puts " 内容 : #{content}"
     puts " 発言者 : #{speaker}"
     puts " 議題 : #{topic}"
     puts " 送信 : #{submit}"
   else
     print "content-type: text/html\n\n"
     print %Q(<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">)
     print %Q(<html lang="ja-JP">)
     print %Q(<HEAD>\n<meta http-equiv="content-type" content="text/html; charset=Shift_JIS">\n<TITLE>)
     print NKF::nkf(&#39;-s&#39;,(CGI::unescape(name)))
     print %Q!</TITLE>\n</HEAD>\n<BODY>\n!
 
   end
   p = WikiPage.new(name).view
   page = Xhtmlparser.new(p,wikihome,footnum,footnote,caption,capnum,level)
   print NKF::nkf(&#39;-sc&#39;,page.do_parse)
 end
 main