moggs has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm looking for a module or simple bit of reliable code which handles multipart form data without the need for using CGI.pm. Any ideas would be greatfully received.

I accept that using CGI.pm is probably the most suitable way, but I'm trying to develop a small stand-alone bit of code which requires all code in one script.

Thanks for your help!

Replies are listed 'Best First'.
Re: multipart/form-data without CGI.pm
by chromatic (Archbishop) on May 24, 2005 at 22:55 UTC

    What you've asked for isn't easy. I think you're making your life harder than I want my life to be. I wrote my own multipart form data parser once. It's very tricky, unless you can guarantee that your users will only ever use one version of one browser on one particular platform.

    If you really, really have to do this with everything in one file, I recommend taking CGI::Simple, stripping out the documentation (70% of the lines of the file), and pasting that into your program.

Re: multipart/form-data without CGI.pm
by tilly (Archbishop) on May 24, 2005 at 23:35 UTC
    Since CGI.pm is in Perl's core, anyone who has Perl will have CGI.pm.

    If they don't have Perl installed, your code won't run anyways...

Re: multipart/form-data without CGI.pm
by mugwumpjism (Hermit) on May 24, 2005 at 23:39 UTC

    PSA::Request::CGI is one CPAN module that does multipart/form-data decoding without relying on any external modules, other than Class::Tangram (which is itself somewhat large, but is only being used as an accessor generator).

    $h=$ENV{HOME};my@q=split/\n\n/,`cat $h/.quotes`;$s="$h/." ."signature";$t=`cat $s`;print$t,"\n",$q[rand($#q)],"\n";