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!