in reply to Reaped:

Well, anyone who's been around here for a while knows that I can't avoid a node like this :)

Your code contains virtually all of the errors that I mentioned in this node. It is not strict compliant and if any form data contains a comma, then your habit of separating multiple values with a comma will not work.

Your line to deal with Server Side Includes is broken for two reasons. See use CGI or die; for a footnote explaining both problems.

higle wrote:

...I couldn't find a straightforward form parsing routine on PM...

It's called CGI.pm. If you need a snippet to grab your form data, try this:

use strict; use CGI qw/:standard/; my %form = map { $_, @{ [param($_)] } > 1 ? [param($_)] : param($_ +) } param();

If you have a single value for a form element, the value in %form will be a scalar. Otherwise, it will be an arrayref. For example, with the following query string:

color=red&color=blue&name=Ovid

You will get the following data structure:

%form = ( 'name' => 'Ovid', 'color' => [ 'red', 'blue' ] );

I know that it's not a lot of fun to see your code commented upon like this. I apologize in advance for any offense, but trust me on this: properly handling form data is considerably more difficult than most people think. I've been doing this for quite a while and while I think I could write my own better than most, I also know that it would still be buggy.

Cheers,
Ovid

Vote for paco!

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.