App::FatPacker::Simple::Tutorial - tutorial!
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.
fatpack-simple script.pl
script.fatpack.pl
script.pl
lib,fatlib,local,extlib
Let's say you have hello.pl and want to fatpack it. And assume
hello.pl
hello.pl uses your modules in lib directory: lib/Hello.pm, lib/Hello/CLI.pm
lib
lib/Hello.pm
lib/Hello/CLI.pm
external cpan module dependencies are declared in cpanfile
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:
fatpack-simple
local
# 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:
--exclude
$ 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!
hello.fatpack.pl
To install App::FatPacker::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::FatPacker::Simple
CPAN shell
perl -MCPAN -e shell install App::FatPacker::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.