When a CGI script is called several environment variables are set and you can access these from Perl. To see what some of the environment variables are you can try the example perl CGI script at
http://www.comp.leeds.ac.uk/cgi-bin/Perl/environment-example
This program simply accesses Perl's associative %ENV array to print out the values of the environment variables. You can have a look at the source of this program to see how it accesses the variables.
Possibly the most useful of these environment variables is the QUERY_STRING variable. In the above example this was the empty string, but if we append, say,
?something
onto the end of the URL then the string after the ? gets put into the environment variable QUERY_STRING. Try opening the following URLs. The first one is the same as we used above.
http://www.comp.leeds.ac.uk/cgi-bin/Perl/environment-example http://www.comp.leeds.ac.uk/cgi-bin/Perl/environment-example?something
http://www.comp.leeds.ac.uk/cgi-bin/Perl/environment-example?1
http://www.comp.leeds.ac.uk/cgi-bin/Perl/environment-example?2
http://www.comp.leeds.ac.uk/cgi-bin/Perl/environment-example?two+words
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment