Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 25th, 2008, 04:09 PM
Lectrician Lectrician is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 48 Lectrician User rank is Private First Class (20 - 50 Reputation Level)Lectrician User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 21 m 2 sec
Reputation Power: 2
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!

Reply With Quote
  #2  
Old November 25th, 2008, 04:29 PM
Axweildr's Avatar
Axweildr Axweildr is offline
'fie' on me, allege-dly
Click here for more information.
 
Join Date: Mar 2003
Location: in da kitchen ...
Posts: 12,123 Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)Axweildr User rank is General 50th Grade (Above 100000 Reputation Level)  Folding Points: 140379 Folding Title: Super Ultimate Folder - Level 1Folding Points: 140379 Folding Title: Super Ultimate Folder - Level 1Folding Points: 140379 Folding Title: Super Ultimate Folder - Level 1Folding Points: 140379 Folding Title: Super Ultimate Folder - Level 1Folding Points: 140379 Folding Title: Super Ultimate Folder - Level 1Folding Points: 140379 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Months 1 Week 1 Day 20 h 31 m 29 sec
Reputation Power: 4323
Send a message via Google Talk to Axweildr
Orkut
use CGI;

It's that simple

perl Code:
Original - perl Code
  1. #!/usr/bin/perl
  2. use CGI;
  3. $q=new CGI;
  4. $name=$q->param('name');
  5. print $name;
Have a look at the CGI documentation on CPAN. It's tried and tested, and frees you up to have fun on other stuff that people haven't already tested to death

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 ...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > Read Form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT