in reply to Re^5: Perl CGI -disabled
in thread Perl CGI -disabled

I understand and I support the removal as a sane way to get Perl out of defaulting to the 90s but it’s not quite fair to say that there are easier alternatives for everything. Yes extensible, scalable, modern, forward-thinking, editable, etc but CGI.pm’s HTML generation and parameter handling is faster and eaiser than templates and I’ll continue to use it in one-offs, helpers, starting or piecing together templates, etc. Knocking this out with a template or a hand rolled .psgi or even mojolicious is more effort. The effort of course may be justified but sometimes it’s all one wants or needs–

perl -MCGI=:all -E 'say header(), start_html(), h1("OHAI"), start_form(), p(textfield("search")), submit("Go"), end_form(), end_html()'

Years of really excellent work went into the kit as messy as is it and it can still be a nice tool when not used for things other than the backbone for a “real” application.

Replies are listed 'Best First'.
Re^7: Perl CGI -disabled
by marto (Cardinal) on Sep 24, 2014 at 07:54 UTC

    At work I maintain some legacy code which uses CGI and CGI::Application, for both of which I employ a templating system since I find it much easier to work with HTML that way. IMHO it's much easier (and takes less time) to keep HTML/CSS/JS separate from perl code.

      I don’t disagree at all. My job is similar. I am just shy of the pervasive, long term slamming and rooting for round-filing CGI.pm. It’s a valuable tool even though I agree it shouldn’t be on the front lines anymore. I think there would be much less home-rolled parameter handling code in the wild, for example, without the oft shown attitude that CGI.pm is somehow toxic.

Re^7: Perl CGI -disabled
by Anonymous Monk on Sep 24, 2014 at 09:05 UTC

    or even mojolicious is more effort.  perl -MCGI=:all -E " say header(), start_html(), h1('OHAI'), start_form(), p(textfield('search')), submit('Go'), end_form(), end_html() "

    I love CGI.pm too, but Mojolicious is just as quick for lots of things :)

    $ mojo generate lite_app RoShamBo.pl [exist] C:\test [write] C:\test\RoShamBo.pl [chmod] RoShamBo.pl 744 $ cat RoShamBo.pl #!/usr/bin/env perl use Mojolicious::Lite; # Documentation browser under "/perldoc" plugin 'PODRenderer'; get '/' => sub { my $c = shift; $c->render('index'); }; app->start; __DATA__ @@ index.html.ep % layout 'default'; % title 'Welcome'; Welcome to the Mojolicious real-time web framework! @@ layouts/default.html.ep <!DOCTYPE html> <html> <head><title><%= title %></title></head> <body><%= content %></body> </html>
    Add a form and
    <h1>OHAI</h1> %= form_for '/' => begin %= text_field 'search' %= submit_button 'Go' % end
    and you're off and running

      Mojolicious is great, especially, in my view, for testing. The equivalent example is *excellent* to include here but please see the irony. The code to point out how easy CGI.pm could be for some things was literally a one-liner. :P

        Mojolicious is great, especially, in my view, for testing. The equivalent example is *excellent* to include here but please see the irony. The code to point out how easy CGI.pm could be for some things was literally a one-liner. :P

        Ease and irony do not count lines :P