Monday, December 05, 2005

 

Perl: CGI Env

That's the basics of perl's builtin data types. We'll through them all
together in the continuation of our script. First, a bit about how CGI
scripts work. Each form element has a name, and when the form is
submitted, the value is associated with its name by make a url of the form

http://hostname/progname?entry1=value1&entry2=value2&textarea=blahblah

If the web server is configured to have "progname" as a CGI script, it
will run that program. CGI is nothing more than a specification of some
environmental variables that the program can use to know the "environment"
it was launched. Values such as the server version, last url referenced,
and authorization information are included in this specification.
Perl offers quick access to the environmental variables through a special
associative array, %ENV.

--------------------------------------------------------------------------------

Example
This line takes the form query (the meat of what we're interested in),
separates into elements dividing on "&", and assigns the list to
@cgiPairs.

################################################################
# Process Query
################################################################
@cgiPairs = split("&",$ENV{'QUERY_STRING'});


Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?