in reply to CGI question
$ perl animal.pl name1=value1 name2=value2
To figure out what name=value pairs your cgi script is expecting, you just need to examine the code. Your cgi script has this in it:
$animal = param('animal');
That line retrieves the value for the name "animal"(which corresponds to the name of an html form element). That means you can run your perl script on the command line if you provide the name animal along with any value that you would have typed into the html form element, e.g.:
$ perl animal.pl animal=tiger
And if you hit return after that, you will get this output:
Content-type: text/html Show me the tiger
In the normal course of things, that text would be sent to a browser, which knows how to interpret the headers (the lines at the beginning of the output that come before two consecutive newlines), and the browser knows how to display the text following the two newlines. In any case, you can quickly find out if the problem you are having is with the cgi script by running it from the command line. Also, running a perl script from the command line is a good way to see exactly what your cgi script is sending to the browser, which may come in handy as your cgi scripts get more complex.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: CGI question
by Anonymous Monk on Feb 09, 2013 at 05:38 UTC |