tags:

views:

176

answers:

5

I just noticed CGI::Simple while looking something up for the CGI.pm module. Should I be using CGI::Simple instead? What will it offer me over CGI.pm, which I've used for eight years? I see that CGI::Simple doesn't do HTML generation; what should I be using for that? And will it integrate with CGI::Simple by allowing me to make form values persist, as CGI.pm does?

+5  A: 

I think it boils down to this line from the docs: "In practical testing this module loads and runs about twice as fast as CGI.pm depending on the precise task."

If you aren't concerned by the speed of your CGI program, I think it is safe to ignore this module. If you are concerned with speed I would suggest you look into CGI::Fast first.

Chas. Owens
Also note that even though it runs twice as fast, that doesn't mean your programs will be twice as fast. Only the tiny bit done by those modules will be faster, and twice as fast as already-fast is still fast. :)
brian d foy
A: 

I'm kinda surprised you're still using CGI at all. Consider a more adult framework like a Catalyst/TT/DBIx stack.

Mark Canlas
I knew that was coming. :) I'm not sure I want to set up a more adult framework for my small inhouse programs, however.
skiphoppy
If a simple tool does the job well, why add in all the extra complexity?
daotoad
A framework isn't always the answer. When you're talking to someone who thinks it is, you can ignore them.
brian d foy
Ouch. CGI is so ugly. What are the odds that it's actually doing what he wants in a productive, maintainable way. I say impossible. Of course a framework isn't always the answer, but it probably and eventually is.
Mark Canlas
Truth be told, I spent yesterday refactoring to make it maintainable. Then in two hours I added enough new features that it's not maintainable again. :) Thankfully it's "just a tool for me," but we all know how that goes.
skiphoppy
To be fair again, though, I think the things making this unmaintainable are what I'm doing with the database, and some of my "business logic." The CGI parts are fairly well done at this point. Neither dealing with CGI nor generating HTML are unmaintainable at this point, although I'm sure they could be better.
skiphoppy
+3  A: 

I have rarely used the HTML generation facilities of CGI.pm. For that, I prefer HTML::Template, usually in conjunction with CGI::Application. CGI::Application can use any $cgi object, specified in the call to its constructor).

I think CGI still has its place. I like CGI::Simple because it provides a clean OO interface.

Sinan Ünür
A: 

You might try CGI::Simple for new things, but otherwise let sleeping dogs lie. If your old programs are working, leave them alone. :)

brian d foy
Well, yes, I'm not going to change old programs ... but for new development, is CGI::Simple preferable? And if so, how should I be generating HTML? (I know, a templating system ... nothing closer to how CGI.pm does it?)
skiphoppy
Like I said, try it and find out if you like it. Take a tour through CPAN and see what else you might like to use.
brian d foy
A: 

CGI.pm has a good install base it, most perl installs have it, a refactored and slightly minimized CGI::Simple doesn't do it for me really. I would have to have a point where I ended up needing CGI.pm for something and maintaining both.

I find the HTML generator of CGI to handle escaping, encoding and solid compliant HTML as a great tool.

hpavc