Perl

Moderators: Jonathan
Number of threads: 1236
Number of posts: 3605

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Edit Report
I have a problem please help me! Posted by Perl learner on 18 Jul 2000 at 12:34 AM
Hey, I have icqed endless programmers and no oen seems to know. . . <br>
Say I haev a form named a, how do I get the value of form a (what was put into it) into the perl variable $a?<br>
<br>
Thanks


Edit Report
Re: I have a problem please help me! Posted by Niels Hilderink on 20 Jul 2000 at 12:51 AM
Put this sub in the bottom of your script:<br>
<br>
sub parse_form {<br>
<br>
#Get the input off the filled-in form<br>
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});<br>
<br>
#Split the pairs name-value<br>
@pairs = split /&/, $buffer;<br>
<br>
#Split the values from the names<br>
foreach $pair (@pairs) {<br>
($name, $value) = split /=/, $pair;<br>
<br>
$value =~ tr/+/ /;<br>
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;<br>
<br>
$FORM{$name} = $value;<br>
}<br>
}<br>
<br>
Now at the beginning of your script active the sub by writing: parse_form();<br>
<br>
now if you've posted a field named "falafel" you get its value like this:<br>
$a = $FORM{'falafel'}<br>
<br>
If you still got problem with it, feel free to email me.





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.