Home: Perl Programming Help: Win32 Programming Help:
Need help on testing cgi on pc


Sep 21, 2000, 1:46 AM

Views: 11458
Need help on testing cgi on pc

I have installed active perl on my pc which is running on Win98.I am trying to test my
HTML form loaded from my brower (IE5) to
accept the input contents to a dat file on the pc. Is it possible or must i do some others settings changes?



Sep 21, 2000, 10:12 PM

Views: 11458
Re: Need help on testing cgi on pc


You can't do that from an html form unless you do it as a SSI if you are just trying to pre-load the form elements.

If this isn't the case, then ...

Here is my suggestion, get Apache Web Server from www.apache.org. Install it and set up a local webserver on your machine. Then run the cgi on your PC.

Or, use Perl Builder 2.0. It allows you to point to an html form and then input the data into the form and Perl Builder will process the cgi output of the script.




Oct 6, 2000, 12:43 PM

Views: 11458
Re: Need help on testing cgi on pc

do you have to process all form info when coming from html and going to dat or txt?
adn if so what are your thoughts on the Apache server???


Oct 6, 2000, 11:21 PM

Views: 11458
Re: Need help on testing cgi on pc

kelvinraj -- Getting CGIs working with PWS is covered in http://www.perlguru.com/forum/Forum11/HTML/000023.shtml

It works just fine, once you get it set up.


Nov 4, 2000, 2:54 PM

Views: 11458
Re: Need help on testing cgi on pc

If all you are trying to do is take the input from the form, and put it in a file, then that is pretty simple. first, make your form send the info to the perl script:

<form action='the url of your script here' method=GET>
<input name=whatever type=text>

Then parse the query string:

my $in;

if ($ENV{'REQUEST_METHOD'} eq "GET") {
$in =~ s/%(..)/pack("c",hex($1))/ge;
$in =~ s/\+/ /g;
$in =~ s/\&/=/g;
%formData = split (/=/, $in);

this puts the data in a hash. you can access it by:

$formData{'whatever you named your inputs'}.

now open a file:

open(DATFILE, '>datfile.txt');

and print to the dat file, in thsi case our data is:

print DATFILE $formData{whatever};

close the data file:

close DATFILE;

Now all of the stuff you posted is in your dat file. Hope this is what you were looking for.