About configurations

MOF Web Based Shopping Cart System @ 2001
Notes on how to work with Perl configuration files for beginners

Table of Contents | FAQ | Installation | Security Issues | Building Input Pages | Formatting
Configurations1 | Configurations2 | About Configurations | Troubleshooting | Customizing

These programs are protected by copyright and may not be resold or distributed. Please see the copyright notice for more information on your end user license for this program.

What's In This Document:

This is a beginners reference for understanding the syntax of all the settings in the mof.conf and mofpay.conf configuration files.

About Perl Configuration Files
How to work with the configuration files: beginners start here

 

 

ABOUT PERL CONFIGURATION FILES Sections LIst How Do I ?

MOF v2.4 uses two configuration files.  The configuration files supply MOF with settings and information that govern its behavior.  As they come in the package, both configuration files have many of MOF's settings turned off, to minimize installation problems.  The idea is to get the system up and running in simple mode, and then begin to turn on features one at a time so any problems can be traced back to a particular function or setting.

 

BASICS OF EDITING CONFIGURATION FILES Sections LIst How Do I ?

The most important rule:

Use an ASCII editor only, do not use a rich text, or fancy word processor to edit the files unless it lets you work in ASCII mode only.  It's nice to use an ASCII editor that will store the file in Unix format, if you are working from a Windows machine, but this is not necessary.  Most of the files are too large for the regular Windows Notepad. Therefore, you may have to find a good ASCII text editor.  Don't use the Windows Word Pad, Word, or an HTML editor to edit the configuration files

I use Edit Pad Pro for windows. Very powerful, loads multiple files fast, does global search-replace, and has syntax color schemes, one for Perl. Find it at: JGsoft.com. They also have a free lite version that may do the job for you.

How to get started

  • mof.conf is the configuration file for the Cart Front End
  • mofpay.conf is the configuration file for the Checkout Back End

Some other basics:

  • Settings are grouped together under CAPITALIZED HEADINGS
    Example:
    # 2. SECURITY SETTINGS
  • In Perl, all comments start with the # character. So, when you see a line like this:
    # this is a comment about something
    You don't need to modify anything past the # character.
    You're looking at notes and the Perl interpreter won't process it as code.
  • When modifying a setting, be very careful to leave all the punctuation intact.  Perl is not like HTML, and it is not forgiving if you leave one little single quote off,  or one little semicolon. The Perl interpreter won't compile the code if a syntax error exists.  If you create a Perl syntax error during your editing, then you'll get an "Internal Server Error" when you try to run the script on your server. 
You'll find 4 types of settings in MOF's configuration files.  The next section will explain more detail about how to work with the different types of settings.  

 

SCALAR VARIABLES, SIMPLE ARRAYS, ASSOCIATIVE ARRAYS Sections LIst How Do I ?

MOF configurations use four different types of settings.  You can tell what type of setting it is by the very first symbol preceding the setting.  Here's a brief table on the four types of settings.  After the table we'll cover some of the more detail rules for working with these types of variables and arrays.  If you are having trouble with a setting and creating a syntax error, the detail rules for each type of setting will help you sort through where the problem might be.

$ precedes a scalar variable (Type: 1, 2)
@ precedes a simple array (Type: 3)
% precedes an associative array (Type: 4)

 

Setting Type What it looks like /  How it works
1 On/Off switches

$


$enable_cc_verify = 1;

This simply turns On (1) or Off (0) the on board credit card verification algorithms.  You can set these to zero (off) or any positive integer (on)

     
2 Text strings

$


$programfile = 'mof.cgi';

This type of setting simply identifies a string of text.  These text settings are used for HTML tags and attributes, messages, filenames, and file pathways.  This example identifies a file that MOF will use.

In a few rare cases, text string settings are used both to declare a text string that will be used by MOF, and as an On/Off switch. We'll point out where that is the case in the configuration help.

     
3 Simple array settings

@


@field_validation = ('HatColor','HatSize');

This is a simple array.  It stores elements in a list.  MOF uses the list to process stuff.  This example is taken from the section USER INPUT OPTIONS in mof.conf.  It simply identifies that both HatColor and HatSize should be required input for a product.

     
4 Associative arrays

%


%product_fields
= ('HatColor','Selected Hat Color',
                   'HatSize','Selected Hat Size');

This is an associative array.  These types of arrays make two column lists where the item in the first column is paired to the item in the second column.  This example is taken from the section USER INPUT OPTIONS in mof.conf

These arrays act like name=value pairs, pairing the string Selected Hat Color with the element HatColor .

 

1. SIMPLE ON/OFF SWITCHES $ Sections LIst How Do I ?

Stick to the syntax rules that you find already in place for a setting.  If it is surrounded by single quotes, double quotes, or no quotes, then use that same syntax.  Remember that the line always ends with the semicolon.

A simple On/Off switch is On (positive number) or Off (0) (Null)
$tax_before_SHI = 0;   -- Off
$tax_before_SHI = 1;
  -- On

These types of settings can be both: On/Off switch and contain usable information:
$use_global_tax = 0;
  -- Off
$use_global_tax = 0.825;
  -- Enables a global tax rate of 8.25 %

Here's an On/Off setting that contains usable text information
$identify_tax_items = "<font size=1 color=gray>Tax</font>";

The above setting not only turns on the feature, but also tells MOF how to print an identifier for taxable or non taxable items.

If you wanted to turn Off that feature it would look like this:
$identify_tax_items = ""
-- (null)

Note: (null) is a set of double quotes "" (or single quotes) '' with nothing (null) between them. Zero is not the same as (null).

 

SINGLE TEXT STRINGS $ Sections LIst How Do I ?

Stick to the syntax rules that you find already in place for a setting.  If it is surrounded by single quotes, double quotes, or no quotes, then use that same syntax.  Remember that the line always ends with the semicolon.

These types of settings can identify a filename
$use_country_list = "countries.txt";

These types of settings can identify html attributes:
$font_preview_titles = '<font face="Arial, Helvetica" size=2>';

Note: the example above uses single quotes to surround a text string.  When single quotes are used then everything between them is treated as exact text.  So, although the embedded double quotes are Perl sensitive characters, it works because single quotes tell Perl to treat everything as text.

Here's another example of an html setting, but surrounded in double quotes:
$action_message_s = "<font face=\"Arial,Helvetica\" size=2 color=navy>";

Note: if any of these type settings surrounded by double quotes use special characters within the double quotes, then the Perl escape character \ must precede any occurrence of a special character.  The above example must precede the inside use of a double quote with the backward slash.  This tells Perl to treat the very next character as text.  Otherwise, Perl would be looking at a broken string, not knowing what to do with 4 sets of double quotes on a single line.  This is a common oversight with beginners.

 

SIMPLE ARRAY SETTINGS @ Sections LIst How Do I ?
  • Simple arrays are lists of elements
  • The whole list of elements are enclosed within parentheses (  )
  • Each element in the list is separated by a comma
  • If an element will be text, then you should surround it in single quotes
  • If an element is numeric, then no quotes are needed
  • The very last element in your list does not have a comma after it
  • The very first element in your list does not have a comma preceding it
  • End the whole array with the semicolon

An array setting can have one element:
@use_shipping = ('custom');

Or it can have multiple elements of both text and numbers
@use_shipping = ('weight',0,0,1);

Notice the rules of surrounding the text in single quotes, numbers without quotes, separated by commas, enclosed in parentheses.

You don't have to keep everything on one line, you can break it all up on individual lines.  Perl allows for liberal white space if it will help you make things more readable.  All rules described above appear in the following example, yet each element is placed on a different line, making it more readable.  Remember to end the list with the ending parenthesis and semicolon );

@field_validation = ('HatColor',
                   'HatSize',
                   'PropellerColor',
                   'BandType');

Here's a list of US states and Canadian Provinces.  This example sets all these states and provinces as domestic for shipping computations.

@domestic_state =
('AL','AZ','AR','CA','CO','CT','DE','DC','FL','GA','ID','IL','IN','IA','KS','KY','LA','ME','MD',
'MA','MI',
'MN','MS','MO','MT','NE','NV','NH','NJ','NM','NY','NC','ND','OH','OK','OR','PA','RI','SC','SD','TN',
'TX','UT','VT','VA','WA','WV','WI','WY','AB','BC','MB','NB','NF','NS','ON','PQ','SK');

 

Associative array settings  % Sections LIst How Do I ?
  • Associative arrays are lists of name=value pairs
  • The whole list of elements are enclosed within parentheses (  )
  • The name and value in the list is separated by a comma
  • And The pairs of name,value are separated by a comma
  • If an element will be text, then you should surround it in single quotes
  • If an element is numeric, then no quotes are needed
  • The very last element in your list does not have a comma after it
  • The very first element in your list does not have a comma preceding it
  • End the whole array with the semicolon

Important: When making these types of arrays, you must always keep order with your name=value pairs.  To explain:  Perl will read the associative array beginning with the first item in your list, the next item in the list is paired with the first .. the third item is paired with the fourth .. the fifth is paired with the sixth .. and so on.  If you have your pairings mixed up then you will get unexpected results.

Here's an example from the tax settings:
%use_state_tax = ('TX',0.0825,'CO',0.053,'CA',0.0922);

This example sets up the following tax rates for different states
(Texas)  TX = 8.25 percent
(Colorado) CO = 5.3 percent
(California) CA = 6.22 percent

You can see the pairings:
Item 1 paired to Item 2
Item 3 paired to Item 4
Item 5 paired to Item 6 ...

Here's an example using the shipping configurations.  This setting instructs MOF what fields to list for shipping, and if that field is required or not.  It also acts as the overall On/Off switch for using the whole shipping information and computations.  In a few short lines, this settings is able to supply MOF with some very complex instructions for handling shipping information input. 

%shipping_destination_fields = (
    'Ecom_ShipTo_Postal_Name_Prefix',0,
    'Ecom_ShipTo_Postal_Name_First',2,
    'Ecom_ShipTo_Postal_Name_Middle',0,
    'Ecom_ShipTo_Postal_Name_Last',2,
    'Ecom_ShipTo_Postal_Name_Suffix',0,
    'Ecom_ShipTo_Postal_Street_Line1',4,
    'Ecom_ShipTo_Postal_Street_Line2',0,
    'Ecom_ShipTo_Postal_Company',0,
    'Ecom_ShipTo_Postal_City',2,
    'Ecom_ShipTo_Postal_StateProv',2,
    'Ecom_ShipTo_Postal_Region',2,
    'Ecom_ShipTo_Postal_PostalCode',4,
    'Ecom_ShipTo_Postal_CountryCode',2,
    'Ecom_ShipTo_Telecom_Phone_Number',0,
    'Ecom_ShipTo_Online_Email',0
);

Notice all the rules are followed: surrounding the text in single quotes, numbers without quotes, separated by commas, enclosed in parentheses, ending in semicolon.  We even placed each name=value pair on a separate line for readability.

Here's a last example taken from the tax settings.  This setting identifies different tax rates for specific postal code areas.  What's a little different about this one is that the zip code looks like a number, but is surrounded in single quotes--meaning it is actually treated like text.  This is very important, because MOF uses this list to match zip code areas that may not always be numbers for different countries.  MOF also uses this pattern to match the starting string, which could not be done with numbers

%use_zipcode_tax = (
    '78745',0.025,
    '78746',0.026,
    '78747',0.027,
    '78748',0.028,
    '78749',0.029,
    '78750',0.030
);

 

 

 

These programs are copyright @ MerchantOrderForm.com, MerchantPal.com 2001