parsing forms with perl...

by Web Services New Zealand <wsnz(at)ihug.co.nz>

 Date:  Sun, 25 Mar 2001 15:07:24 +1200
 To:  hwg-languages(at)hwg.org
  todo: View Thread, Original
Hi,

I'm using a fairly standard method of processing form input into variables, 
which I've pasted in below. My problem is that it comes out in alphabetical 
order of input type name, and I was hoping to retain it in the order that 
it appears in the form.

I normally do this sort of thing in C, which does this, and PERL is 
something I'm just having to use for this cgi. Any help as to what I need 
to do to stop the reordering?

Thanks
Kyle

/*
#!/usr/bin/perl

my $method = $ENV{'REQUEST_METHOD'};

if ($method eq "GET") {
     $rawdata = $ENV{'QUERY_STRING'};
} else {
    read(STDIN, $rawdata, $ENV{'CONTENT_LENGTH'});
}

my @value_pairs = split (/&/,$rawdata);
my %formdata = ();

foreach $pair (@value_pairs) {
     ($field, $value) = split (/=/,$pair);
     $value =~ tr/+/ /;
     $value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
     $formdata{$field} = $value;
}

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

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA