Initself's Retarded Guide to Building a Package

To build a package, use Module::Install, ya turkey!

Update: Per mstpan, one should not use Module::Install!

cpan Module::Install


Make a directory for your package to reside:

mkdir /home/you/My-Package


Put your module in the 'lib' directory. This is where all your code is going to live.

mkdir lib
mkdir
My
touch
My/Package.pm


Put your code in My/Package.pm, or copy the file you already wrote here.

Then, create a Makefile.PL in /home/you/My-Package:

use inc::Module::Install;

# Define metadata
name          
'My-Package';
perl_version  
'5.006';
version        
'0.01';
license        
'perl';

# Specific dependencies
test_requires  
'Test::More'  => '0.42';

WriteAll;


Then, just run your new shiny file, pal!

perl Makefile.PL && make && make install && make clean && rm Makefile.old


While your at it, put that in a file called 'install.sh' so you can execute that each time you install it. You've gotta be root to run this sucker!

Update: Don't install to system root! Use plenv!

sudo sh install.sh


Afterwards, your directory will looks like this:

inc/  install.sh*  lib/ Makefile.PL  META.yml


You're installed!

1 Comment

Thanks for your post which will definitely help others. However, you are responsible for handling everything right. There are a couple of modules on CPAN that could make this job even easier.

My personal favorite is to use Dist::Zilla to handle everything around managing my packages. The only thing you will have to do is to maintain a small file named dist.ini in the top directory of your module and everything else will get generated for you. Simply install Dist::Zilla and make the dzil executable your friend -- you will love it!

Leave a comment

Sign in to comment.

About initself

user-pic Perl is better than sliced bread. Way better.