<?php
define("ABS_PATH", $_SERVER['DOCUMENT_ROOT']);
include(ABS_PATH . "/head_nav.php");
include(ABS_PATH . "/middle.php");
?>
          <div class="section">
            <div class="toc-wrapper">
              <span class="toc-title">Contents:</span>
              <ul class="toc">
                  <li class=""><a href="#SYNOPSIS">SYNOPSIS</a></li>
                  <li class=""><a href="#DESCRIPTION">DESCRIPTION</a></li>
                  <li class=""><a href="#PUBLIC_METHODS">PUBLIC METHODS</a></li>
                  <li class="sub"><a href="#method_new">new(\%config)</a></li>
                  <li class="sub"><a href="#method_error">error($msg, ...)</a></li>
                  <li class="sub"><a href="#method_debug">debug($msg, ...)</a></li>
                  <li class="sub"><a href="#method_module_version">module_version()</a></li>
                  <li class=""><a href="#AUTHOR">AUTHOR</a></li>
                  <li class=""><a href="#COPYRIGHT">COPYRIGHT</a></li>
                  <li class=""><a href="#SEE_ALSO">SEE ALSO</a></li>
              </ul>
            </div>
          </div>
          
                <div class="pod">
            <div class="section">
              <div class="head">
                <h1 id="SYNOPSIS">SYNOPSIS</h1>
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
              </div>
              <div class="body">
                <pre>package My::Module;
use base qw( Template::Base );

sub _init {
    my ($self, $config) = @_;
    $self-&gt;{ doodah } = $config-&gt;{ doodah }
        || return $self-&gt;error("No 'doodah' specified");
    return $self;
}

package main;

my $object = My::Module-&gt;new({ doodah =&gt; 'foobar' })
    || die My::Module-&gt;error();</pre>
              </div>
            </div>
            <div class="section">
              <div class="head">
                <h1 id="DESCRIPTION">DESCRIPTION</h1>
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
              </div>
              <div class="body">
                <p>
                      Base class module which implements a constructor and error reporting
                      functionality for various Template Toolkit modules.
                    </p>
              </div>
            </div>
            <div class="section">
              <div class="head">
                <h1 id="PUBLIC_METHODS">PUBLIC METHODS</h1>
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
              </div>
              <div class="body">
                <div class="subsection">
                  <div class="head">
                    <h2 id="method_new" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">new(\%config)</h2>
                    <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
                  </div>
                  <div class="body">
                    <p>
                          Constructor method which accepts a reference to a hash array or a list of
                          <code>name =&gt; value</code> parameters which are folded into a hash.
                          The <code>_init()</code> method is then called, passing the configuration
                          hash and should return true/false to indicate success or failure. A new
                          object reference is returned, or undef on error. Any error message raised
                          can be examined via the <a href="#method_error">error()</a> class method
                          or directly via the <code>$ERROR</code> package variable in the derived
                          class.
                        </p>
                        <pre>my $module = My::Module-&gt;new({ ... })
    || die My::Module-&gt;error(), "\n";

my $module = My::Module-&gt;new({ ... })
    || die "constructor error: $My::Module::ERROR\n";</pre>
                  </div>
                </div>    <div class="subsection">
                  <div class="head">
                    <h2 id="method_error" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">error($msg, ...)</h2>
                    <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
                  </div>
                  <div class="body">
                    <p>
                          May be called as an object method to get/set the internal
                          <code>_ERROR</code> member or as a class method to get/set the
                          <code>$ERROR</code> variable in the derived class's package.
                        </p>
                        <pre>my $module = My::Module-&gt;new({ ... })
    || die My::Module-&gt;error(), "\n";

$module-&gt;do_something() 
    || die $module-&gt;error(), "\n";</pre>
                        <p>
                          When called with parameters (multiple params are concatenated), this
                          method will set the relevant variable and return undef. This is most
                          often used within object methods to report errors to the caller.
                        </p>
                        <pre>package My::Module;

sub foobar {
    my $self = shift;

    # some other code...

    return $self-&gt;error('some kind of error...')
        if $some_condition;
}</pre>
                  </div>
                </div>    <div class="subsection">
                  <div class="head">
                    <h2 id="method_debug" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">debug($msg, ...)</h2>
                    <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
                  </div>
                  <div class="body">
                    <p>
                          Generates a debugging message by concatenating all arguments passed into
                          a string and printing it to <code>STDERR</code>. A prefix is added to
                          indicate the module of the caller.
                        </p>
                        <pre>package My::Module;

sub foobar {
    my $self = shift;

    $self-&gt;debug('called foobar()');

    # some other code...
}</pre>
                        <p>
                          When the <code>foobar()</code> method is called, the following message is
                          sent to <code>STDERR</code>:
                        </p>
                        <pre>[My::Module] called foobar()</pre>
                        <p>
                          Objects can set an internal <code>DEBUG</code> value which the
                          <code>debug()</code> method will examine. If this value sets the relevant
                          bits to indicate <code>DEBUG_CALLER</code> then the file and line number
                          of the caller will be appened to the message.
                        </p>
                        <pre>use Template::Constants qw( :debug );

my $module = My::Module-&gt;new({
    DEBUG =&gt; DEBUG_SERVICE | DEBUG_CONTEXT | DEBUG_CALLER,
});

$module-&gt;foobar();</pre>
                        <p>
                          This generates an error message such as:
                        </p>
                        <pre>[My::Module] called foobar() at My/Module.pm line 6</pre>
                  </div>
                </div>    <div class="subsection">
                  <div class="head">
                    <h2 id="method_module_version" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">module_version()</h2>
                    <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
                  </div>
                  <div class="body">
                    <p>
                          Returns the version number for a module, as defined by the
                          <code>$VERSION</code> package variable.
                        </p>
                  </div>
                </div>
              </div>
            </div>
            <div class="section">
              <div class="head">
                <h1 id="AUTHOR">AUTHOR</h1>
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
              </div>
              <div class="body">
                <p>
                      Andy Wardley &lt;abw@wardley.org&gt; <a
                      href="https://wardley.org/">https://wardley.org/</a>
                    </p>
              </div>
            </div>
            <div class="section">
              <div class="head">
                <h1 id="COPYRIGHT">COPYRIGHT</h1>
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
              </div>
              <div class="body">
                <p>
                      Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
                    </p>
                    <p>
                      This module is free software; you can redistribute it and/or modify it
                      under the same terms as Perl itself.
                    </p>
              </div>
            </div>
            <div class="section">
              <div class="head">
                <h1 id="SEE_ALSO">SEE ALSO</h1>
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
              </div>
              <div class="body">
                <p>
                      <a href="../../modules/Template.php">Template</a>
                    </p>
              </div>
            </div>
            
            </div>
<?php include(ABS_PATH . "/footer.php"); ?>
