But honestly doesn't that seem like more work than just printing it?
Yes, it does. And to the original poster, please don't use CGI.pm to generate HTML. It's a horrible, horrible sin against humanity. Not only do you have the usual flaws of embedding the html(presentation) in your code(control), you don't even make the html in an easily recognizable form. It's in some bizarre CGI.pm language which is a pain in the ass to find.
| [reply] |
| [reply] |
Disagreeing is fine, this is perl after all, but my main criticism of CGI.pm's html generating function is not that they are easy to use, it is that they are very ugly. Do you honestly find:
print table(tr(td(a(-href=>'http://google.com',"http://google.com"))))
easier to read than
print "<table><tr><td><a href='http://google.com'>http://google.com</a
+></td></tr></table>";
?
As for templates, I've yet to see a situation where *not* using templates is better design. People often refuse to use them, mostly due to false laziness (but occasionally it is a good laziness), but that doesn't make it good design. | [reply] [d/l] [select] |
I wonder what's worse. Some guy writing code the way he wants (using CGI.pm) or some (HTML::)Template( Toolkit) zealot...
Your reaction is nothing but a Pavlovian reaction. Instead of explaining what is wrong with producing CGI.pm HTML in a normal way, you try to make the OP look bad for even talking about CGI.pm. You don't know anything about the project (s)he's working on, so you can't tell wheter using CGI.pm is really a bad choice.
Just because you think(/read that) using CGI.pm for HTML creation is bad, doesn't mean that others can't be happy with it.
Please, please give some more structured criticism instead of this zealotry.
--
b10m
All code is usually tested, but rarely trusted.
| [reply] |
Which part of Not only do you have the usual flaws of embedding the html(presentation) in your code(control), you don't even make the html in an easily recognizable form. Did you not understand? I present two clear criticisms. One is that embedding the html generation in the code is usually a bad idea REGARDLESS OF THE APPLICATION. The second is that the embedded form of the code is extremely ugly when you use CGI.pm. Using CGI.pm to produce html leads to complicated overdone code that is hard to read and understand.
And yes, templates are good, but I'd much rather see the person just use prints statements to output the html, rather than the horrible functions exported by CGI.pm.
Update Just a node responding to both replies: Nothing I have said precluded the possibility of keeping the script as one file. Any sane templating system (HTML::Template, just for example) will let you embed the template *in* the same file as your script is, for example below the __DATA__ line, or even just as a giant quoted string.
| [reply] |