http://www.travelagency.com/cgi-bin/find.pl?dest=Costa%20Rica&date=Jun%203Notice that, to send a blank, the browser had to insert the sequence
%20
. There are a number of similar encodings which must be used to send
characters which are not legal in URLs or filenames. Once again, the CGI
module will
spare us the need to worrry about these details. It's worth noting, however, that
if you don't want to bother with filling out a form to pass information to your
CGI program, referencing a URL constructed in this way will serve the same purpose,
allowing a single CGI program to serve many different purposes. If you need to
convert a string to its URL-encoded form, you can use the HTML::Entities
module.
Variables sent to your program with this scheme are transferred in the environmental
variable QUERY_STRING
; you can examine $ENV{QUERY_STRING}
for the gory
details. Variables sent to your program using fill-in forms transmit that information
through the headers, however. Thus, while it is certainly possible to get information
from a CGI program without invoking special modules, most programmers prefer the
convenience of using the CGI module, if for nothing else to retrieve
parameters from
encoded URLs and fill out forms using a common interface, and without having to
confront the specific details of how the information is transmitted.