NAME

App::FatPacker::Simple::Tutorial - tutorial!

SUMMARY

If you execute fatpack-simple script.pl, then you will get script.fatpack.pl that is the fatpacked script.pl with all modules in lib,fatlib,local,extlib directories. Also note that the all modules are automatically perl-stripped.

TUTORIAL

Let's say you have hello.pl and want to fatpack it. And assume

  • hello.pl uses your modules in lib directory: lib/Hello.pm, lib/Hello/CLI.pm

  • external cpan module dependencies are declared in cpanfile

so that you have:

$ find . -type f
./cpanfile
./hello.pl
./lib/Hello/CLI.pm
./lib/Hello.pm

$ cat cpanfile
requires 'Sub::Retry';
requires 'HTTP::Tiny';

Well, fatpack-simple just fatpacks a script with all modules in lib,fatlib,local,extlib, so let's install dependencies to local directory first:

# if you have carton, then:
$ carton install

# or just:
$ cpanm -Llocal -nq --installdeps .

# Oh, HTTP::Tiny is not core module for old perls, so we have to fatpack it too!
$ cpanm --reinstall -Llocal -nq HTTP::Tiny

# Oh, Sub::Retry depends on 'parent' module, so we have to fatpack it too!
$ cpanm --reinstall -Llocal -nq parent

Now the whole dependencies are in lib and local directories, it's time to execute fatpack-simple. However if you use perl 5.20+, then cpanm installed configure deps Module::Build, CPAN::Meta, right? They are not necessary for runtime, so execute fatpack-simple with --exclude option:

$ fatpack-simple --exclude Module::Build,CPAN::Meta hello.pl
-> perl strip Hello.pm
-> perl strip Hello/CLI.pm
-> perl strip parent.pm
-> exclude CPAN/Meta.pm
...
-> perl strip HTTP/Tiny.pm
-> exclude Module/Build.pm
...
-> perl strip Sub/Retry.pm
-> Successfully created hello.fatpack.pl

Finally you get hello.fatpack.pl!