in reply to Re^2: Module Problems
in thread Module Problems

A Reply to myself. I just realized that the routine breakupForms isn't returning a thing!
Heres the code
package formBreaker;

use strict;
sub breakupForms {
        my (%pform,%gform);
        my $submittype = @_;
        #Do the Form {Post} first

        read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});
        my @pairs = split(/&/, $buffer);

        foreach $pair (@pairs) {
                my ($name,$value);
                ($name, $value) = split(/=/, $pair);
                $name =~ tr/+/ /;
                $name =~ s/%(a-fA-F0-9a-fA-F0-9)/pack("C", hex($1))/eg;

                $value =~ tr/+/ /;
                $value =~ s/%(a-fA-F0-9a-fA-F0-9)/pack("C", hex($1))/eg;

                if($pform{$name} ne "") {
                        $pform{$name} = join("\|",$pform{$name},$value);
                }
                else {
                        $pform{$name}=$value;
                }
        }

        #breakup form query strings
        my @pairs = split(/\&/,$ENV{'QUERY_STRING'});
                foreach(@pairs) {
                        my($name,$value);
                        ($name,$value) = split(/\=/,$_);
                        $gform{$name}=$value;
                }

        if($submittype eq "post") {
                return %pform;
        }
        elsif($submittype eq "get") {
                return %gform;
        }
} #end of sub for breakupForms
1;

Replies are listed 'Best First'.
Re^4: Module Problems
by ikegami (Patriarch) on Oct 23, 2004 at 18:41 UTC
    Save yourself some headaches and use CGI. No use reinventing the wheel yet again
      How does CGI handle a form where multiple elements are being submitted with the same name, for example a select box with the multiple element activated and the form submits the same name with like 5 different values. Will it overwrite the previous? or does it have something to fix it?
        It's described in the description of the param sub in the module's docs. If you're just gonna do what CGI does, why not use CGI?