NAME

PropertyList.pm - A module for processing PropertyList files and data types


SYNOPSIS

 $property = propertyFromString($string);
 $string = stringFromProperty($property, $options);


DESCRIPTION

Definition of a PropertyList

A PropertyList is a Perl object being either a dictionary (hash), array (list) or string. A dictionary or array may contain any of the other data types (where the keys for dictionaries are strings).

String representations of PropertyLists

A string representation of a dictionary is enclosed in braces and represents entries of the dictionary as ``key = value;''. key is a string and value is the string representation of any of the allowed PropertyList data types.

Example for a dictionary:

 {
        key = value;
        dictionary = { key2 = anotherDictionary; };
 }

The string representations of arrays are enclosed in parantheses and seperated by commas.

Example of an array:

 ( string1, { dict = first; }, ( list, in , list), end )

A string is represented as a literal if it only contains characters from the following character class [_\/\-a-zA-Z0-9.]. Otherwise a string is enclosed into inverted commas. Inverted commas inside a string are escaped by a backslash.

Examples of strings:

 simpleString
 /a/path/which/needs/no/quoting
 "a more complex O'string"
 "\"inverted commas\" within a string"

Example of a more complex PropertyList:

 {
        aList = ( { flag = 1; }, { flag = 2; } );
        programOption1 = "do not print any insensible output";
        "a key can be complex" = ( what, should, we, do,
                ( and, a, list, again) );
 }

Whitespace is used for option separation. C-comments starting in '/*' and ending in '*/' are permitted in positions where whitespace is allowed.

Use of the functions

The functions provided by this module are simply to switch between the two representations as either native Perl data types or strings. propertyFromString will emit a die when encountering a syntax error. stringFromProperty take a hash options which can be used to modify the formatting of the string representation. Without options any entry in either a dictionary or a list is placed on a separate line. You can set the value of screenWidth within the array. In this case all entries of a dictionary or array are accumulated until they exceed the specified width. Should this happen, all entries are again split to one line each. This options helps to produce a compact on screen display of PropertyLists since this option works recursively, producing a single line only if the whole dictionary fits within.