CGI and Perl

Configuration of HyperCalThe Variables File

All of HyperCal's configuration variables are located in a separate file named "variables." By carefully reading over the configuration file, you can get an idea of what HyperCal does and how to configure it. Listing 11.2 shows the "variables" file for HyperCal.

Listing 11.2. Variables and configuration file for HyperCal.

 #  Names of the various program files
 #  Some sites only allow cgi's with a .cgi extension
 #  so you might need to change your file names
 # Other files
 # variables
 #  Are you running a secure site with personal accounts?
 #  Number of days to keep past dates
 # Your info goes here - dont make this me, please
 $admin="Richard Bowen";
 # Person to contact with problems
 # URL of the directory in which these files live
 # Title of the calendar.
 #  Location of the .htpasswd and .htgroup files
 #  This will be used only if you are running the security part
 @linkto=(" Home Page", "/perl/~~My Perl archive");
 #  Places to provide links to on each page.
 #  This array contains the locations of images for the various
 #  months.  The format is:
 #  "url_for_icon~~url_for_background~~bgcolor~~link~~visited link"
 #  This array must contain 12 elements. Any field where you have
 #  no preference, indicate by "none"

Notice which elements of the program are located in the configuration file. The first two blocks define the names of the supplementary programs and the names and locations of various configuration files. These locations are different on different software platforms and flavors of UNIX, so placing them in a configuration file instead of hard coding them into your code significantly increases your ability to easily get your CGI running on different servers. In general, anything that you might want to change, or will change based on the software environment of your CGI, should be defined in a configuration file.

Arrays are a great way to store variables with multiple elements, like the month_images in the
preceding example. Notice that the last line of code uses a return value to verify the successful loading of the file to the main program.

by BrainBellupdated