{
    "mode": "perldoc",
    "parameter": "Template::Base",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Template%3A%3ABase/json",
    "generated": "2026-06-11T10:23:03Z",
    "synopsis": "package My::Module;\nuse base qw( Template::Base );\nsub init {\nmy ($self, $config) = @;\n$self->{ doodah } = $config->{ doodah }\n|| return $self->error(\"No 'doodah' specified\");\nreturn $self;\n}\npackage main;\nmy $object = My::Module->new({ doodah => 'foobar' })\n|| die My::Module->error();",
    "sections": {
        "NAME": {
            "content": "Template::Base - Base class module implementing common functionality\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "package My::Module;\nuse base qw( Template::Base );\n\nsub init {\nmy ($self, $config) = @;\n$self->{ doodah } = $config->{ doodah }\n|| return $self->error(\"No 'doodah' specified\");\nreturn $self;\n}\n\npackage main;\n\nmy $object = My::Module->new({ doodah => 'foobar' })\n|| die My::Module->error();\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Base class module which implements a constructor and error reporting functionality for various\nTemplate Toolkit modules.\n",
            "subsections": []
        },
        "PUBLIC METHODS": {
            "content": "new(\\%config)\nConstructor method which accepts a reference to a hash array or a list of \"name => value\"\nparameters which are folded into a hash. The \"init()\" method is then called, passing the\nconfiguration hash and should return true/false to indicate success or failure. A new object\nreference is returned, or undef on error. Any error message raised can be examined via the",
            "subsections": [
                {
                    "name": "error",
                    "content": "my $module = My::Module->new({ ... })\n|| die My::Module->error(), \"\\n\";\n\nmy $module = My::Module->new({ ... })\n|| die \"constructor error: $My::Module::ERROR\\n\";\n\nerror($msg, ...)\nMay be called as an object method to get/set the internal \"ERROR\" member or as a class method\nto get/set the $ERROR variable in the derived class's package.\n\nmy $module = My::Module->new({ ... })\n|| die My::Module->error(), \"\\n\";\n\n$module->dosomething()\n|| die $module->error(), \"\\n\";\n\nWhen called with parameters (multiple params are concatenated), this method will set the\nrelevant variable and return undef. This is most often used within object methods to report\nerrors to the caller.\n\npackage My::Module;\n\nsub foobar {\nmy $self = shift;\n\n# some other code...\n\nreturn $self->error('some kind of error...')\nif $somecondition;\n}\n\ndebug($msg, ...)\nGenerates a debugging message by concatenating all arguments passed into a string and printing\nit to \"STDERR\". A prefix is added to indicate the module of the caller.\n\npackage My::Module;\n\nsub foobar {\nmy $self = shift;\n\n$self->debug('called foobar()');\n\n# some other code...\n}\n\nWhen the \"foobar()\" method is called, the following message is sent to \"STDERR\":\n\n[My::Module] called foobar()\n\nObjects can set an internal \"DEBUG\" value which the \"debug()\" method will examine. If this value\nsets the relevant bits to indicate \"DEBUGCALLER\" then the file and line number of the caller\nwill be append to the message.\n\nuse Template::Constants qw( :debug );\n\nmy $module = My::Module->new({\nDEBUG => DEBUGSERVICE | DEBUGCONTEXT | DEBUGCALLER,\n});\n\n$module->foobar();\n\nThis generates an error message such as:\n\n[My::Module] called foobar() at My/Module.pm line 6\n\nmoduleversion()\nReturns the version number for a module, as defined by the $VERSION package variable.\n"
                }
            ]
        },
        "AUTHOR": {
            "content": "Andy Wardley <abw@wardley.org> <http://wardley.org/>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.\n\nThis module is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Template\n",
            "subsections": []
        }
    },
    "summary": "Template::Base - Base class module implementing common functionality",
    "flags": [],
    "examples": [],
    "see_also": []
}