in reply to multipart/form-data without CGI.pm

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.