Arc Forumnew | comments | leaders | submitlogin
3 points by eric256 5923 days ago | link | parent

Looks like perl hasn't been represented much.

Why not just the following?

        use strict;
        use warnings;

        use CGI;
        use CGI::Session;

        my $cgi     = new CGI;
        my $session = new CGI::Session();

        print $session->header();

        $session->param('name', $cgi->param('name')) if ($cgi->param("name"));
        $session->clear('name')                     if ($cgi->param("c"));

        if ($cgi->param("m") eq 'show') {
          print "You said:", $session->param("name"), " ", $cgi->a({href=>'?c=1'},'Start Over');
        } elsif ($session->param("name")) {
          print $cgi->a({href=>'?m=show'},'See what you said');

        } else {
          print $cgi->startform, $cgi->textfield('name'), $cgi->submit('Submit'), $cgi->endform;
Its simple, its short, and its easy to read, I would guess that anyone from any language should be able to read it. All session and cookie stuff is taken care of automatically, and best of all its easy to expand. Best of all the HTML creation is explicit and the provided examples could be easily replaced with direct HTML or a template system.