Ruby 掲示板 などの参考資料

一応、参考としてGET で動かしてみた、コードは
''''''''
#!C:/Ruby32_x64/bin/ruby

print "Content-type:text/html","\n","\n"

print "<!DOCTYPE html><html lang=\"ja\"><head><meta charset=\"UTF-8\"><title></title></head><BODY BGCOLOR=\"#ffffff\"><h1>test decoder</h1>","\n"
#   print "it test."
# decode            #デコードをcoll
# def decode
# end

in_d = {
    "apple" => "iphon",
    "banana" => "150",
    "cherry" => "200"
}
# come = in_d["comment"]
in_d["あまおう苺"] = "250"
 print "りんごは",in_d["apple"],"円<br>","\n"
in_d["apple"] = "110" #要素の値の変更
 print "支払いりんごは",in_d["apple"],"円<br>","\n"
 print "あまおう苺は",in_d["あまおう苺"],"円<br>","\n"
#
print "ローカルに来たよ。<br>\n","\n";
# buf = STDIN.read(ENV["CONTENT_LENGTH"])
 buf = ENV["QUERY_STRING"]      #これは、解決した。全部アドレスバーに出る。
 print buf,"<br>","\n"

array = buf.split("&")
n=0
for i in 0..(array.length-1) do
print n,"?",array[n]," array_n<br>\n"

(my_key,my_val) = array[n].split("=")
print my_key,",",my_val," a2<br>\n"
if my_val != ""
 my_key.gsub!(/%([0-9a-fA-F][0-9a-fA-F])/) { $1.hex.chr }
 else
 my_key = ""
 my_val = ""
end
if my_val != ""
 my_val.gsub!(/%([0-9a-fA-F][0-9a-fA-F])/) { $1.hex.chr }
 else
 my_val = ""
end


print my_key,"=",my_val," koko<br>","\n"
in_d[my_key] = my_val
#in_d.push = { my_key => "my.",my_val,"yen" }
print in_d[my_key]," hashy<br>","\n"
n += 1
end
key_array = in_d.keys
n=0
key_array.each do |element|
#  puts(element)
  print n," ",element,"<br>","\n"
  print n," ",element," in_d[element]=",in_d[element],"<br>","\n" #配列なのか連想配列なのか見た目区別がつかない　test=[0,1,2,] test {"1" =>1,"2"=>2,"3"=>3}
  n += 1
end

print in_d["apple"],in_d["name"],"ここはきたよ2<br>\n","\n";#appleは?


# print "it test.3"
# form    #フォーム書き出しcoll


# def form

#print (日本語テスト<br>ENV "SCRIPT_NAME" <br>\n);

# print "<form action=\"http://127.0.0.1/my_ruby/ruby_test.cgi\" method=\"POST\">","\n"
print "<form action=\"http://127.0.0.1/my_ruby/ruby_test.cgi\" method=\"GET\">","\n"
print "<table border=0 cellspacing=1>","\n"
print "<tr><td><b>name</b></td><td><input type=text name=name size=28 value=\"",in_d["name"],"\" maxlength=\"12\" class=f></td></tr>","\n"
# print "<tr><td><b>email</b></td><td><input type=text name=email size=28 value=\"",in_d["email"],"\" maxlength=\"36\" class=f></td></tr>","\n"
print "<tr><td><b>submit</b></td><td><input type=text name=subm size=36 value=\"",in_d["subm"],"\" maxlength=\"36\"class=f></td></tr>","\n"
print "<tr><td colspan=2><b>comment</b><br><textarea cols=70 rows=7 name=comment wrap=\"soft\" class=f>",in_d["comment"],"</textarea></td></tr>","\n"
print "<tr><td><b>url</b></td><td><input type=text size=52 name=url value=\"",in_d["url"],"\" maxlength=\"60\" class=f></td></tr>"+"\n"
# print "<tr><td><b>password</b></td><td><input type=password size=28 name=password value=\"",in_d["password"],"\" maxlength=\"12\" class=f></td></tr>","\n"
print "<tr><td><input type=submit value=\"submit\"></td><td><input type=reset value=\"reset\"></td></tr>","\n"
print "</form></table><br>","\n"

print "name=",in_d["name"],"<br>",come,"<br>It OK?<br>","\n"
# print()内に改行してはいけない(テキスト的に) html <!-- -->コメントを入れてはいけない　{}の文字として書き出しには\{\}としなければならない ""を使ってはならない\"\" \nと次の先頭をくつけてはならない。
# \n をやると、終わらねばならない。print は機能が高すぎる。変数が変数として区別できるか?

# end
key_array = in_d.keys
# key_array << in_d.keys     # key_array[] += [in_d.keys] #変数か配列か区別がつかないだろう? arr[1]1の要素を除く?3つが2つに
# key_array.push(in_d.keys)
m =key_array.length-1
print key_array.length,"length",in_d.keys,",",m,"<br>","\n" # (0)="[]"?

print "key_array[2]=",key_array[2],"<br>","\n"   #"\n"は中身を変数としてh0d0aとして、展開している。\n=h0d0aである違いは出力として使う

n=0
key_array.each do |element|
#  puts(element)
  print n," ",element,"<br>","\n"
  print n," ",element," in_d[element]=",in_d[element],"<br>","\n" #配列なのか連想配列なのか見た目区別がつかない　test=[0,1,2,] test {"1" =>1,"2"=>2,"3"=>3}
  n += 1
end

print "<br>next1<br>","\n"

n = 0 #変数に再定義いうか内容を変えられない?
 for i in 0..(key_array.length-1) do  #ループの自己変数を使い間違いてかえられるのを特徴とするかバグとするかだけ
#	print n,"<br>","\n"
    print n,"=",key_array[n],"は:",in_d[key_array[n]],"<br>","\n"
	n += 1
 end

print "</body></html>","\n"
exit
''''''''
動かせる範囲に、みんな動かせればベストだが努力はします。