M
Milo Thurston
I am attempting to convert a script that produces csv output into
a CGI script that will produce an html table. The following code
is the best I can think of (shown here with an example of the
data):
switch_summary = ["1,2,3,4,5","6,7,8,9,10","11,12,13,14,15"]
# example output
cgi.out do
cgi.html do
cgi.head { "\n"+ cgi.title{"Title"} + "\n" } +
cgi.body {
cgi.h1 { "A pox on cgi scripting"} +
cgi.table {
switch_summary.each do |val|
cgi.tr {
val.split(",").to_a.each do |l|
cgi.td {"#{l}"}
end
} + "\n"
end
}
}
end
end
However, rather than producing a table with each element of the array
to a line, and each number to a separate cell it produces this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"><HTML><HEAD>
<TITLE>Title</TITLE>
</HEAD><BODY><H1>A pox on cgi
scripting</H1><TABLE>1,2,3,4,56,7,8,9,1011,12,13,14,15</TABLE></BODY></HTML>
I'd therefore be grateful if anyone would explain why, and also point me
in the direction of anything that explains cgi scripting without
assuming prior knowledge of Perl, for example (I was no good at cgi
scripts with that language, either).
Thanks.
a CGI script that will produce an html table. The following code
is the best I can think of (shown here with an example of the
data):
switch_summary = ["1,2,3,4,5","6,7,8,9,10","11,12,13,14,15"]
# example output
cgi.out do
cgi.html do
cgi.head { "\n"+ cgi.title{"Title"} + "\n" } +
cgi.body {
cgi.h1 { "A pox on cgi scripting"} +
cgi.table {
switch_summary.each do |val|
cgi.tr {
val.split(",").to_a.each do |l|
cgi.td {"#{l}"}
end
} + "\n"
end
}
}
end
end
However, rather than producing a table with each element of the array
to a line, and each number to a separate cell it produces this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"><HTML><HEAD>
<TITLE>Title</TITLE>
</HEAD><BODY><H1>A pox on cgi
scripting</H1><TABLE>1,2,3,4,56,7,8,9,1011,12,13,14,15</TABLE></BODY></HTML>
I'd therefore be grateful if anyone would explain why, and also point me
in the direction of anything that explains cgi scripting without
assuming prior knowledge of Perl, for example (I was no good at cgi
scripts with that language, either).
Thanks.