in reply to Using CGI.pm

(TIMTOWTDI!)
Personally I prefer CGI::Lite over CGI. For me I find the interface much cleaner than CGI, and it's drastically faster, not having to load thirteen million subroutines for doing every possible thing someone might conceive doing with cgi/html. For example to get your form data you just do:
my $c = new CGI::Lite; my %post = $c->parse_form_data('POST');
or to get cookies you just call parse_cookies(). But this is all the module does, just parse forms and cookies, it doesn't bother with all the bastardized html functions (Which I deeply, deeply hate, but thats another story) and other assorted nonsense CGI comes with.

As to html, I vastly prefer using HTML::Template for all of my html needs. And another advantage to both of these modules is that they're "pure perl" meaning all you would have to do is download cgi-lite.tar.gz, make a folder on your website called 'CGI' and then upload the file called 'Lite.pm' to that folder, then presto, you can instantly use CGI::Lite;.

Replies are listed 'Best First'.
Re: Re: Using CGI.pm
by Deanimal (Acolyte) on Nov 18, 2003 at 22:51 UTC

    Excellent answer, BUU. I'll give CGI::Lite a try because parsing forms is all I'm working with right now. Minimalism appeals to me.

    I'm not sure what you mean by "bastardized html functions," but I'm perfectly happy to write my own HTML and CSS. I hand-code everything and know my way around the specs at W3C.org quite well. So I'm not looking for a mod to help with the markup - maybe later if I see the need but certainly not now.

    Thanks also for the installation instructions.

    Take care,
    Dean (aka D9r)

      the 'bastardized html functions' are all the little ones that CGI.pm comes with.. p(),hr(), etc.
Re: Re: Using CGI.pm
by Deanimal (Acolyte) on Nov 19, 2003 at 01:05 UTC

    BUU wrote:
    "For example to get your form data you just do:"

    my $c = new CGI::Lite; my %post = $c->parse_form_data('POST');

    Will that work for a post request that contains a query string? Like this:

    <form method="post" action="script.cgi?choice=one">
      Well, to be pedantic, no the above code wouldn't, as it only specifies the POST data. If you wanted the query string you would just call it with 'GET' as an arguement: my %get = $c->parse_form_data('GET');. If you wanted both types of paramaters in one hash then you would need to merge them some how. How you merge depends on how you want to treat duplicates and such.

        Cool. That gives me enough to work with and figure it out. Thanks for the help.