in reply to Parse multipart/form-data with MIME::Parser
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parse multipart/form-data with MIME::Parser
by jcb (Parson) on Apr 23, 2021 at 23:03 UTC | |
by choroba (Cardinal) on Apr 25, 2021 at 22:38 UTC | |
|
Re^2: Parse multipart/form-data with MIME::Parser
by Anonymous Monk on Apr 22, 2021 at 07:28 UTC |