> CGI, which I've decided to not use
Good for you! What did you use instead?
There are modules that do most of the work for you. For example, using Plack::Request, which is still rather low level, you can just write:
#!/usr/bin/perl
use strict;
use warnings;
use Plack::Request;
sub {
my $req = 'Plack::Request'->new(shift);
my %method = (
GET => sub { [<DATA>] },
POST => sub { ['Hello ', $req->body_parameters->{text}] });
my $action = $method{ $req->method }
or return [405, [Allow => join ', ', keys %method], []]
+;
return [200, ['Content-type' => 'text/html'], $action->()]
}
__DATA__
<html><body>
<form method=post>
Your name: <input name=text>
<p>
<input type=submit value=Submit>
</form>
</body></html>
Update: This code is wrong, see jcb's note.
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
|