View on
Jim Bacon > Module-Cooker-v0.1_6 > Module::Cooker



Annotate this POD

Module Version: v0.1_6   Source  


Module::Cooker - Module starter kit based on Template


Version v0.1.4


 use Module::Cooker;
 my $mc = Module::Cooker->new( %params );


You are probably more interested in the command line interface to this module: modcooker



Here are the default vaues for the attributes:

 my $defaults = {
     minperl   => '',
     author    => 'A. Uthor',
     email     => '',
     profile   => 'default',
     package   => 'My::MC::Module',
     version   => 'v0.1_1',
     extravars => {},
     localdirs => [],
     nosubs    => 0,

A string representing the name of the package/module. I.e. My::New::Module


A string representing the minimum version of Perl require to use the module. I.e. 'v5.8.8' or '5.8.8' or even '5.008008'. Default: '' (empty string)


A string with the author's name. Default: '' (empty string);


A string with the author's email. Default: '' (empty string);


The profile from which the module should be built from. Default: 'default'


A string representing the version of the new module. Default: 'v0.1_1'


This option creates a hash ref that is eventually passed as part of the data structure that Template will use as substitution variables. Any element in the hash ref can be accessed as extra.element_name in a template file.


The directory (or directories if specified multiple times) to search in addition to the standard distrubution profile directory for the profile named by the '--profile' parameter. This is built as an array ref. Default: []


Boolean flag indicating that subdirectories in the profile should NOT be searched for template files. (Will probably be removed in the next release.) Default: 0


There is a read-only accessor provided for each of the parameters accepted by new.

You can also obtain a hash (or hashref) with the values for each parameter by using the "summary" method described below.



This is the method that does the real work of the module. Based upon the parameters used to construct the object, it will search the profile directory(ies) for the specified profile. It will then build a list of files in the profile to be processed by Template.

The processed files will be placed under a distribution directory created in the current directly. A MANIFEST will be built at the completion of this processing.

An exception will be thrown if the distribution directory already exists.


 print $mc->dist_name . "\n";   # prints My-MC-Module

Read-only method that returns the name of the distrubution as derived from the package name. This is the name that is used to create the top-level directory for the distrubution. '::' sequences are transformed to '-' in accordance with normal CPAN practice.


 print $mc->module_name . "\n";   # prints

Read-only method that returns the name of main module in the distrubution. This is derived by taking the final element of the package name and appending '.pm' to it.


Read-only method that returns a list of directories that contain a sub-directory with the same name as the requested profile.

The method will return either an array or array reference depending upon the calling context.


 my $template_data = $mc->template_data;
 my %template_data = $mc->template_data;
 print Dumper($template_data);
 $VAR1 = {
   'author' => {
     'name'  => 'A. Uthor'
     'email' => '',
   'modcooker' => {
     'version' => '0.01'
     'perlver' => '5.010001',
   'package' => {
     'name'       => 'My::MC::Module',
     'dist_name'  => 'My-MC-Module',
     'version'    => 'v0.1_1',
     'minperl'    => '',
     'libpath'    => 'lib/My/MC',
     'module'     => ''
     'modulepath' => 'lib/My/MC/',
     'timestamp'  => '2013-11-28 16:40:23',
     'year'       => '2013'

Read-only method that returns a copy of the data that will be passed to Template to be used for variable substitution. It should be noted that this is a copy and changes made to the returned structure will not affect what is actually passed on.

The method will return either a hash or hash reference depending upon the calling context.


Read-only method that returns the absolute path to where the module is located in the @INC search path with the name of this module (Cooker) appended. This is used to located the module's standard template directories.


Read-only method that returns the absolute path to where the standard profiles are located in the distribution.


 my $summary = $mc->summary;
 my %summary = $mc->summary;
 print Dumper($summary);
 $VAR1 = {
   'nosubs'    => 0,
   'profile'   => 'default',
   'localdirs' => [],
   'version'   => 'v0.1_1',
   'author'    => 'A. Uthor',
   'extravars' => {},
   'package'   => 'My::MC::Module',
   'minperl'   => '',
   'email'     => ''

Read-only method that returns a copy of the data stored in the internal attributes after object construction. It should be noted that this is a copy and changes made to the structure will not affect the object itself.

The method will return either a hash or hash reference depending upon the calling context.


Jim Bacon, <jim at>


Please report any bugs or feature requests to bug-module-cooker at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

You can also submit an issue via the GitHub repository listed below.


You can find documentation for this module with the perldoc command.

    perldoc Module::Cooker

You can also look for information at:


This module draws heavily upon ideas found in Distribution::Cooker, ExtUtils::ModuleMaker and Module::Starter.

Special thanks goes to Perl Monk tobyink for the module name regex pattern and the Perl Monks who assisted with peer review of the code, test suite, and documentation.


Template, Jose's Guide for Creating Perl modules


Copyright 2013 Jim Bacon.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See for more information.

syntax highlighting: