#include defs.wh
#include defs.wh2
#define _PAGE-TITLE_ Perl API
#define _TITLE-HEADER-TEXT_ Perl API
#include head.wh

It is possible to write extensions to <i>Webc</i> in perl.
These extensions are stored in files, and loaded in with
the <i>#localcode</i> directive.
<p>
Functions can be called in a couple of ways.
The currently preferred style is called from a webc file like:
<pre>
    &#035;localcode calculate.lc
    Calculate(3 * 4 + 5)
</pre>

<p>

The localcode file might look something like:
<pre>
   &#035;
   &#035;   calculate.lc
   &#035;
   &#035;   This defines the function Calculate which evaluates an
   &#035;   expression and returns the value.
   &#035;
   use vars qw(%Callable);

   sub Calculate
       {
       my($args) = @_;
       my($result);

       $args =~ s/[^\d\-+*\/()]//g;
       eval("\$result = $args");
       return $result;
       }

    $Callable{'Calculate'} = 1;		# Let the function be called
    return 1;
</pre>

In this case, the string returned by the function is what is used
in the webc file to replace the call.

<p><hr><p>

There are a number of variables that you should know about.
The <i>%Symbols</i> hash is the symbol table.  Perl code is free
to play with the symbols.
<p>
The <i>OUT</i> file handle is the current output stream (normally).
Things written to this stream are put into the HTML output file.

#include tail.wh2
#include tail.wh
