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: General Discussions: General Questions:
parsing text from cgi file

 



obrien135
Novice

Nov 22, 2012, 8:48 AM

Post #1 of 2 (11709 views)
parsing text from cgi file Can't Post

When you write to a file from a text area in an html program, for some reason it puts a + sign in for every space that was entered by the viewer. How do you parse those out and replace them with spaces ? When I print them to screen from the file the +'s are still there. The cgi peogram thatdoes the reading and writing of the file, and input and output from the html code is a perl file:




#!/usr/bin/perl
print "Content-type: text/html\n\n";

$TheReq = "-";
if($ENV{"REQUEST_METHOD"} eq 'GET'){$TheReq = $ENV{"QUERY_STRING"}}
else
{read(STDIN, $TheReq, $ENV{"CONTENT_LENGTH"})}
#print $TheReq;
open(OUT, '>>file.txt') or die "Couldn't open file.txt file, \n";
#print("hello world1");
select(OUT);
printf "<HTML><P>%s<BR></P></HTML>", $TheReq;
select(STDOUT);
#print("hello world2");
close(OUT);
$TheReq = "";

#print("hello world3");
open(A, "<file.txt");
while (<A>) {
chomp;
print"<HTML><P>%s<BR></P></HTML>", $_;
}
close (A);


(This post was edited by obrien135 on Nov 22, 2012, 1:23 PM)


FishMonger
Veteran / Moderator

Nov 23, 2012, 6:25 AM

Post #2 of 2 (11216 views)
Re: [obrien135] parsing text from cgi file [In reply to] Can't Post

Use the CGI module to read/parse the form submission.

http://search.cpan.org/~markstos/CGI.pm-3.63/lib/CGI.pm

 
 


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

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