First, make sure you have a proper shebang for perl. /bin/perl? I rarely see perl installed in /bin, but if it's indeed there then forget it.
Modern perl scripters no longer craft hacks to read form data from standard input primitively. In those code, POST form data used to be read from <STDIN> according to CGI specification, from which the content in the form of &-separated key=value pairs are usually extracted with a combination of split() and regular expressions. You may still find examples with code like this. However, this is prone to errors and is no longer recommended. The Perl community has agreed on a common standard - the CGI module. If your tutorial doesn't mention the CGI module, it should be considered out of date already and you ought to cast some questioning glances on it.
Here I modified your script a little bit to put in the missing parts. The CGI module knows how to find out whether a POST or GET form is involved, and then read and extract form data with the appropriate method for you. No fiddling of those dirty things required anymore:
Some perl people actually recommend you to use the CGI object exclusively to output the form completely with its API rather than hardcoding the HTML tags in print() statements, but I think this is just a matter of taste. Isolating form snippet in templates and construct form output dynamically with a template engine (such as Template Toolkit) is seen as an even better approach.
Just put the script (mycgi.pl) in your Web server, give it executable chmod, and that should work. It should work if you have a reasonably recent version of CGI. It should be, if your Perl version is recent enough. The CGI module is shipped with Perl by default.
Last edited by cbkihong; 02-12-2005 at 11:00 PM..
Reason: use $cgi->header() instead of legacy way
hi. im very new to perl. is it possible to fill up a web form and submit it using perl? example, i would like to sign up for a yahoo account though a perl script (ofcourse, granting the "type the characters as shown in imgage" is absent)? (8 Replies)
i have a HTML report file..its in attachment(a part of the whole report is attached..name "input html.doc").also its source is attached in "report source code.txt"
i just want to seperate the datas like in first line it should be..
NHTEST-3848498958-NHTEST-10.2-no-baloo a
and so on for whole... (3 Replies)
I am trying to add to a Web page that I have, the ability to have users make requests as long as they key in a password.
Can anyone help me with validating the text from the text field on the Web page into UNIX?
Please let me know if I need to be clearer.
Thanks, (1 Reply)
I have a perl script that prints up the html code and executes a few korn scripts to populate the web code.
Disclaimer === I can throw together some korn scripts pretty quick. This code changes pretty frequently. I don't know enough about perl to do everything I need. One day maybe I'll get... (4 Replies)
I need to process a file line-by-line using some value from a shell variable
Something like:perl -p -e 's/$shell_srch/$shell_replace/g' input.txt
I can't make the '-s' work in the '-p' or '-n' input loop (or couldn't find a syntaxis.)
I have searched and found... (4 Replies)
Hi please help me with this .
I have a file test.txt with following content
$cat test.txt
<td>$test</td>
<h2>$test2</h2>
and I have a ksh with following content
$cat test.ksh
#!/bin/ksh
test=3
test2=4
while read line
do
echo $line
done < test.html
I am expecting the output as (4 Replies)
<tr><td bgcolor=#D7EBAD><b>Instructions :</b></td>
<td>`cat temp.txt`</td></tr>
Hi Experts,
I have an requirement of displaying file contents in HTML mail , for which am using the above approach, Where as the output is kind of not as expected.
If there are 5 lines in the file, in the... (4 Replies)
Dear All ,
i stuck in one problem executing xml .. i have input xml as
<COMMAND name="ARRANGEMENT.WRITE" timestamp="0" so="initial">
<SVLOBJECT>
<LONG name="CSP_PMNT_ID" val="-1"/>
<MONEY name="CSP_CEILING" amount="0.0" currency="AUD"/>
... (6 Replies)
Hi ,
I need an help in perl scripting.
I have an perl script written and i have an for loop in that ,where as it writes some data to a file and it has details like below.
cat out.txt
This is the first line
this is the second line.
.....Now, this file needs to be send in mail in HTML... (2 Replies)
I have a below syntax its working fine...
var12=$(ps -ef | grep apache | awk '{print $2,$4}')
Im getting expected output as below:
printf "%b\n" "${VAR12}"
dell 123
dell 456
dell 457
Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)