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

Thanks all your replies were very helpful; its a subtle effect of -disabled . Still seems undesirable to leave this out of the post, since if I only wanted to display the value, I would have just printed it, and not had it in an input text box with a name and value.

I am familiar with *readonly*, and in fact it's what I ended up using. It still allows users to CLICK in the box however, which yields email to me like "hey I can't CHANGE this value- why??". When they cant click in the box it behaves like any other static page text, and I don't get those questions.. My javascript guy is seeing if he can get me some .css type that prevents clicking in the box.

Wow like 4 great replies, with no haters, flames, or abuse. Things are looking up here! Kudos guys :)

THanks again,
MP

Replies are listed 'Best First'.
Re^5: Perl CGI -disabled
by marto (Cardinal) on Sep 23, 2014 at 14:06 UTC

    As an aside, I have to ask do you really need to use CGI, and if so is there a reason you're not using some templating mechanism (e.g. HTML::Template/Template)? The reason I ask is that it's no secret that the module itself is quite dated, and can make life really quite difficult for you. The documentation states:

    CGI.pm HAS BEEN REMOVED FROM THE PERL CORE

    "The rational for this decision is that CGI.pm is no longer considered good practice for developing web applications, including quick prototyping and small web scripts. There are far better, cleaner, quicker, easier, safer, more scalable, more extensible, more modern alternatives available at this point in time. These will be documented with CGI::Alternatives."

      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.

        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.

        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