
obrien135
Novice
Nov 22, 2012, 8:48 AM
Post #1 of 2
(20408 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)
|