in reply to Storable: freeze/unfreeze

See the node use CGI or die;. You should not parse CGI form data by hand.

  1. print "Content-type:text/html\n\n";

    There should be a space between the colon and the t.

  2. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

    You don't check to see if the read was successful. Does the length match CONTENT_LENGTH?

  3. @pairs = split(/&/, $buffer);

    The semicolon is an alternate delimeter that will be supported more in the future. This will break your code.

  4. $value =~ s/\r//g; # remove hard returns
  5. $value =~ s/\cM//g; # delete ^M's

    Do you realize that \cM is the same as \r?

  6. $FORM{$name} = $value;

    Whoops! If we have multiple values, you've just overwritten them.

You can replace all of that broken code with the following three lines:

use CGI qw/ :cgi-lib :standard /; print header; my %FORM = Vars;

Cheers,
Ovid

Vote for paco!

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