The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
[%#
  # IMPORTANT NOTE
  #   This documentation is generated automatically from source
  #   templates.  Any changes you make here may be lost.
  # 
  #   The 'docsrc' documentation source bundle is available for download
  #   from http://www.template-toolkit.org/docs.html and contains all
  #   the source templates, XML files, scripts, etc., from which the
  #   documentation for the Template Toolkit is built.
-%]
[% META book = 'Modules'
        page = 'Base'
%]
[%  WRAPPER toc;
	PROCESS tocitem 
	        title ="SYNOPSIS"
                subs  = [];
	PROCESS tocitem 
	        title ="DESCRIPTION"
                subs  = [];
	PROCESS tocitem 
	        title ="PUBLIC METHODS"
                subs  = [
                    "new(\\%config)",
		    "error(\$msg, ...)",
		    "debug(\$msg, ...)"
		];
	PROCESS tocitem 
	        title ="AUTHOR"
                subs  = [];
	PROCESS tocitem 
	        title ="VERSION"
                subs  = [];
	PROCESS tocitem 
	        title ="COPYRIGHT"
                subs  = [];
	PROCESS tocitem 
	        title ="SEE ALSO"
                subs  = [];
    END
%]
<!-- Pod to HTML conversion by the Template Toolkit version 2 -->
[% WRAPPER section
    title="SYNOPSIS"
-%]<pre>    package My::Module;
    use base qw( Template::Base );</pre>
<pre>    sub _init {
	my ($self, $config) = @_;
	$self-&gt;{ doodah } = $config-&gt;{ doodah }
	    || return $self-&gt;error(&quot;No 'doodah' specified&quot;);
	return $self;
    }</pre>
<pre>    package main;</pre>
<pre>    my $object = My::Module-&gt;new({ doodah =&gt; 'foobar' })
        || die My::Module-&gt;error();</pre>
[%- END %]
[% WRAPPER section
    title="DESCRIPTION"
-%]<p>
Base class module which implements a constructor and error reporting 
functionality for various Template Toolkit modules.
</p>
[%- END %]
[% WRAPPER section
    title="PUBLIC METHODS"
-%][% WRAPPER subsection
   title = "new(\\%config)"
-%]<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 
_init() 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 error() class method or directly via the package variable ERROR
in the derived class.
</p>
<pre>    my $module = My::Module-&gt;new({ ... })
        || die My::Module-&gt;error(), &quot;\n&quot;;</pre>
<pre>    my $module = My::Module-&gt;new({ ... })
        || die &quot;constructor error: $My::Module::ERROR\n&quot;;</pre>
[%- END %]
[% WRAPPER subsection
   title = "error(\$msg, ...)"
-%]<p>
May be called as an object method to get/set the internal _ERROR member
or as a class method to get/set the $ERROR variable in the derived class's
package.
</p>
<pre>    my $module = My::Module-&gt;new({ ... })
        || die My::Module-&gt;error(), &quot;\n&quot;;</pre>
<pre>    $module-&gt;do_something() 
	|| die $module-&gt;error(), &quot;\n&quot;;</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;</pre>
<pre>    sub foobar {
	my $self = shift;</pre>
<pre>	# some other code...</pre>
<pre>	return $self-&gt;error('some kind of error...')
	    if $some_condition;
    }</pre>
[%- END %]
[% WRAPPER subsection
   title = "debug(\$msg, ...)"
-%]<p>
Generates a debugging message by concatenating all arguments
passed into a string and printing it to STDERR.  A prefix is
added to indicate the module of the caller.
</p>
<pre>    package My::Module;</pre>
<pre>    sub foobar {
	my $self = shift;</pre>
<pre>	$self-&gt;debug('called foobar()');</pre>
<pre>	# some other code...
    }</pre>
<p>
When the foobar() method is called, the following message
is sent to STDERR:
</p>
<pre>    [My::Module] called foobar()</pre>
<p>
Objects can set an internal DEBUG value which the debug()
method will examine.  If this value sets the relevant bits
to indicate DEBUG_CALLER then the file and line number of
the caller will be appened to the message.
</p>
<pre>    use Template::Constants qw( :debug );</pre>
<pre>    my $module = My::Module-&gt;new({
        DEBUG =&gt; DEBUG_SERVICE | DEBUG_CONTEXT | DEBUG_CALLER,
    });</pre>
<pre>    $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>
[%- END %]
[%- END %]
[% WRAPPER section
    title="AUTHOR"
-%]<p>
Andy Wardley &lt;abw@wardley.org&gt;
</p>
<p>
[% ttlink('http://wardley.org/', 'http://wardley.org/') -%]
</p>
[%- END %]
[% WRAPPER section
    title="VERSION"
-%]<p>
2.77, distributed as part of the
Template Toolkit version 2.19, released on 27 April 2007.
</p>
[%- END %]
[% WRAPPER section
    title="COPYRIGHT"
-%]<pre>  Copyright (C) 1996-2007 Andy Wardley.  All Rights Reserved.</pre>
<p>
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
</p>
[%- END %]
[% WRAPPER section
    title="SEE ALSO"
-%]<p>
[% ttlink('Template', 'Template') -%]
</p>
[%- END %]