Name

$:

Synopsis

When looking up information with the $( and $) operators it is sometimes desirable to provide a default return value, should the lookup fail. Default values are specified with the $: operator, which fits between the $( and $) operators like this:

LHS....      $( name key $:  default  $)

Here, name is the symbolic name you associated with a dbtype (Section 23.2.2) using the K configuration command. The key is the value being looked up, and default is the value to be placed in the workspace if the lookup fails.

To illustrate, consider the following rule:

R $+ < @ $* . fax >        $: $1 < @ $(faxdb $2 $: faxhost $) >

Here, any address that ends in .fax (such as bob@here.fax) has the host part ($* or the here) looked up in the faxdb database (the $2 is the key). If that host is not found with the lookup, the workspace is changed to user<@faxhost> (or, for our example, bob@faxhost).

See Section 23.4.1 for a complete description of the $: operator as it is used with database maps.

Get Sendmail, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.