The sdk_installdir/examples directory includes sample CGI utilities and applications implemented in both C and Perl.
The Perl code below is a simple CGI script that generates the HDML deck described in the previous section. A line-by-line description follows the code.
1#!/usr/local/bin/perl5.001push (@INC, "../apputils");require 'HDMLUtils.pl';#$AppUtils::CGIStandard;$DECK = "<HDML VERSION=3.0> <DISPLAY> Hello Unwired World! </DISPLAY> </HDML>";#Output the deck&AppUtils::OutputDeck($DECK);This line identifies the Perl version to use. Change this line as needed for your server. Note that if you are calling UP.SDK Perl utilities (as this program does), you must use Perl 5.001 or higher.
These lines include the HDMLUtils.pl utility file provided in the UP.SDK. This file defines the OutputDeck() function, which the application uses to output HDML. Note that the push statement assumes that the UP.SDK Perl utilities are in the apputils directory, within the current directory's parent directory. Be sure to modify this for your own directory structure.
These lines define the HDML deck--the same deck used in Testing a static HDML deck on your Web server.
This line uses the OutputDeck() utility function to send the deck as an HTTP response. The OutputDeck() function outputs the HDML and adds the HTTP header to it. It has the same result as the following lines of code:
The OutputDeck() function assumes that your Web server follows Netscape conventions and automatically adds the HTTP/1.0 status line to the HTTP response header. If your Web server does not follow Netscape conventions, uncomment line 6 by removing the hashmark (#). This sets a flag that instructs the OutputDeck() function to include the status line.
For a complete description of the OutputDeck() and other sample Perl utilities, see the UP.SDK Tools and APIs Reference.
To test the CGI program with the UP.Simulator, follow these steps.
It is recommended that you use a .cgi extension. Make sure that your Web server maps the .cgi extension to a Perl 5 interpreter. Also make sure you have set the program's file permissions so that it is executable.
To make the program accessible to the UP.Simulator, you must put it in a directory that is served by your Web server.
The procedure for starting the UP.Simulator is described in Using the UP.Simulator.
The UP.Simulator displays the card shown in Figure 3-5. The only difference is the URL in the Go field.