
perlkid
stranger
Mar 3, 2000, 12:59 AM
Post #4 of 7
(3415 views)
|
Yes, You can put this sub at the bottom of the program <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> sub parse_form { my (@pairs, %in); my ($buffer, $pair, $name, $value); if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); } else { &cgierr('You cant run this script from telnet/shell.'); } PAIR: foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; ($value eq "---") and next PAIR; exists $in{$name} ? ($in{$name} .= "~~$value") : ($in{$name} = $value); } return %in; } </pre><HR></BLOCKQUOTE> and at the top with all of your variables you can put %in = &parse_form; then you could use it like so, if($in{'id'} eq "footer") {&footer_html;} perlkid
|