|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Read Form
I am writing a script and am using the data from the URL and FORMS.
I am using the below code to produce the strings in a useable mannor (code very similar to that used in YaBB as I have been using this as a refference). [perl]sub read_input { # Create INFO hash my $env = $ENV{QUERY_STRING}; @pairs = split(/;/, $env); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $INFO{$name} = $value; } # Create FORM hash read(STDIN, $FormData, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $FormData); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } }[/perl] This gives me the output of a form name as $FORM{'itemname'} This does not seem to work for <select multiple> type form inputs, as the string is over written by the previous multiple entry each time. What is the best way to recover from this!?! I would like to have the results from a multiple select box to produce a commar seperated (or other seperated) list such as $FORM{'multiple'}="lemon,pear,apple" for example. Thanks very much for any input! |
|
#2
|
|||||
|
|||||
|
use CGI;
It's that simple perl Code:
CPAN's your buddy, get to know him ...
__________________
--Ax without exception, there is no rule ... heavyhaulage.ie Targeted Advertising Cookie Optout (TACO) extension for Firefox The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones ![]() 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0 Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. -- Jamie Zawinski Detavil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > Read Form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|