2.8. Expressions


2.8.1. Introduction

Expressions are used in several places within SDF including:

The value of an expression can be placed into a paragraph by delimiting it with the special symbols [[ and ]]. For example:

   The current file is [[DOC_FILE]].

2.8.2. Types of expressions

An expression is either:

If an expression is a single word, it is the value of a variable. Otherwise, it is evaluated as a Perl expression. A Perl expression is typically one of the following:


2.8.3. Accessing variables within Perl expressions

Within a Perl expression, SDF variables are available via the var associative array. The syntax used by Perl for accessing a value within an associative array is:

  "$" array_name "{" string_index "}"

Some examples are:

  1. get the length of the DOC_AUTHOR variable:
      length($var{'DOC_AUTHOR'})
  1. concatenate the document name and type:
      "$var{'DOC_NAME'} $var{'DOC_TYPE'}"