CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Parsing Multi selected lists with Perl

 



version2
Deleted

May 7, 2001, 10:30 AM

Post #1 of 6 (1028 views)
Parsing Multi selected lists with Perl Can't Post

Hi all! Using the code below:


read(STDIN,$submit,$ENV{'CONTENT_LENGTH'});

foreach $pair (split('&', $submit))
{
if ($pair =~ /(.*)=(.*)/)
{
($key,$value) = ($1,$2); # get key, value.
$value =~ s/\+/ /g; # substitute spaces for + signs.
$value =~ s/%(..)/pack('c',hex($1))/eg;
$inputs{$key} .= "\0" if (defined($inputs{$key}));
$inputs{$key} = $value; # Create Associative Array.
}
}

I am losing all of my lists that have multiple selected items because that key/value pair is being overwritten. I just cant find the reason why this is happening. Thanks in advance.




rjoseph
Novice

May 7, 2001, 2:12 PM

Post #2 of 6 (1023 views)
Re: Parsing Multi selected lists with Perl [In reply to] Can't Post

WOAH!!!! NO!!!!

I think, by looking at that code, that you are using this code to parse incoming GET/POST CGI requests, right?

DO NOT DO IT THIS WAY!! The CGI modules are written by Lincoln Stien, one of major players in the Perl community - I garuntee (no offense) that he knows a TON more than you (and me, and...) - I think that you can trust him (*cough* sarcasm *cough*).

So PLEASE PLEASE PLEASE use CGI;

On a related note, here is probably the best reasoning for using CGI I have ever seen.

r j o s e p h
"Violence is a last resort of the incompetent" - Foundation


version2
Deleted

May 7, 2001, 2:21 PM

Post #3 of 6 (1022 views)
Re: Parsing Multi selected lists with Perl [In reply to] Can't Post

Actually, I got the problem licked. But I appreciate your post.



rjoseph
Novice

May 7, 2001, 4:33 PM

Post #4 of 6 (1019 views)
Re: Parsing Multi selected lists with Perl [In reply to] Can't Post

You're welcome :)

Just please always use CGI when you are programming for the web - don't try to roll your own.

r j o s e p h
"Violence is a last resort of the incompetent" - Foundation


Jasmine
Administrator / Moderator

May 8, 2001, 2:21 AM

Post #5 of 6 (1016 views)
Re: Parsing Multi selected lists with Perl [In reply to] Can't Post

I definitely agree with rjoseph. CGI.pm is much more reliable and stable than hand-rolling your own input parser.

Check out this thread -- Parsing forms...

And just to show you how easy it is to use CGI.pm for form parsing...


Code
#!/usr/bin/perl 

use CGI qw/:standard/;

@multivalue = param( 'scrolling_list_formfield' );
$single = param( 'textbox' );

Just something to think about... :)



version2
Deleted

May 8, 2001, 6:16 AM

Post #6 of 6 (1012 views)
Re: Parsing Multi selected lists with Perl [In reply to] Can't Post

Thanks to everyone for the help and the advice. :) I appreciate it.


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives