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:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old August 8th, 2000, 12:00 AM
grusein grusein is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Puerto Vallarta, Jalisco, Mexico
Posts: 3 grusein User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi.

I´m a new user of perl and I need to use POST to send data to a perl program.

I follow diferents examples and I can't print the values of the form.

I think that I'm grong in STDIN.

The code that I am using is the next:

-------------html form---------
<form method=POST action="test4.pl">

<input type="text" name="email">
<input type="text" name="envio2">

<input type="submit" value="submit">
</form>
---------------------------------

-------perl program--------------
#!D:InetPubwwwrootclientesnettimesartnet
print "Content-type: text/htmlnn";

&parse_form;

sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|n)*-->//g;
$value =~ s/<([^>]|n)*>//g;
$FORM{$name} = $value;
}
}
----------------------------------

Thanks for your help and sorry about my english. URL

Reply With Quote
  #2  
Old August 8th, 2000, 05:01 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 9
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
grusein,

just try the following .You have to print the parsed values from your form like $FORM{'email'}.


#!/usr/local/bin/perl

print "Content-type: text/htmlnn";

&parse_form;

print "Email:".$FORM{'email'};
#print email here

sub parse_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|n)*-->//g;
$value =~ s/<([^>]|n)*>//g;
$FORM{$name} = $value;
}
}

Good Luck!!

------------------
SR -
webshiju.com

"The fear of the LORD is the beginning of knowledge..."

Reply With Quote
  #3  
Old August 8th, 2000, 08:18 AM
JonLed JonLed is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2000
Location: Indiana
Posts: 614 JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level)JonLed User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 h 49 m 49 sec
Reputation Power: 9
You don't have to use $FORM{'email'}... you can use $FORM{email} (no single quotes). I'm only mentioning this to save some confusion (because you're parse routine doesn't have those quotes in them.)

Reply With Quote
  #4  
Old August 8th, 2000, 01:21 PM
grusein grusein is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2000
Location: Puerto Vallarta, Jalisco, Mexico
Posts: 3 grusein User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I include the print "Email2: ".$FORM{'email'}; with and wihthout quotes and my var is empty.
Do you thing that something is wrong in the server of my ISP?
Is working over Windows NT and Perl 5.003_07.
If I use GET in the form, I can see all the data, but when I use POST, I can read any thing.
Thanks for your time.


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > why STDIN doesn't work??


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


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





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway