home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Previous Section Next Section

$( $)

Perform a database-map lookup/action RHS operators

The $( and $) operators perform a wide range of actions. They can be used to look up information in databases, files, or network services, or to perform transformation (such as dequoting), or to store values in macros. These operators make many customizations possible. Their simplest use might look like this:

R $-         $: $( faxusers $1 $) look up in a database
R $-         $: $( dequote  $1 $) perform a transformation

In the first line, the intention is for users listed in the faxusers database to have their mail delivered by fax instead of by email. Any lone username in the workspace (matched by the $-) is looked up (the $1 inside the $( and $) operators) in the faxusers database. If that username is found it that database, the workspace is replaced by the value for that name (perhaps something such as user@faxhost). If the user is not found in the database, the workspace is unchanged.

The second line looks for any lone username in the workspace, and dequotes (removes quotation marks from) that name using the built-in dequote type (dequote).

Note that the $( and $) operators can be used only on the RHS of rules. They are fully explained in Section 23.4.

    Previous Section Next Section