descriptionBundle Perl modules inside Perl programs
ownerflavio@polettix.it
last changeSun, 6 Oct 2024 13:11:35 +0000 (6 15:11 +0200)
content tags
add:
readme

NAME

mobundle - bundle modules inside your scripts


VERSION

Ask the version number to the script itself, calling:

   shell$ mobundle --version


USAGE

   mobundle [--usage] [--help] [--man] [--version]
   mobundle [--autoscan|--scan|-a] [--body|-b <body>]
            [--body-from|--script|--program|-B <filename>]
            [--head|-h <head>] [--head-from|-H <filename>]
            [--head-from-body|-S <n>] [--head-from-paragraph|-P]
            [--module|-m <name>] [--modules-from|-M <filename>]
            [--output|-o <filename>] [--standard-head|-s]


EXAMPLES

   shell$ mobundle -m Template::Perlish -B yourscript.pl
   shell$ mobundle -m Template::Perlish --head '#!/path/to/perl' -B yourscript.pl
   shell$ mobundle -m Acme::Laugh --head-from-paragraph -B laugh.pl


DESCRIPTION

mobundle lets you bundle Perl modules inside your Perl script, in order to ship a single script instead of N separate files.

The underlying logic is simple: all modules are included in the generated script, and the module loading mechanism is tweaked in order to let you load the bundled modules. See the documentation for perlfunc/require to understand how.

The generated script will be compound of three main parts: a head, a section with the bundled modules and the logic to load them, and a body. Briefly speaking:

head

this is where you should put your shabang and the uses that you would like to happen before the module loading mechanism is tweaked.

The head is guaranteed to start at the very first octet in the result, so you can put a shabang.

modules

this part is generated automatically based on your instructions about which modules should be bundled.

body

this is the body of your script, i.e. what your script is supposed to do. It will likely contain either uses or requires that need the modules that are bundled in the modules section.

Why Another? Use PAR!

PAR is fantastic: lets you bundle all the needed components of your application inside a single executable, and ship it. But... there's a niche that it's not able to cover, at least looking at the documentation.

In particular, there seem to be two different operation modes, depending on your needs

My need was somewhere in between: on the one side I wasn't willing to bundle the interpreter, on the other I couldn't ensure that PAR was available.

In particular, this kind of need arises every time that my programs only need Pure-Perl modules, that do not need any platform-specific installation process. In this case, bundling the interpreter means restricting the applicability to one (or more, at some cost) platform only; the other way is simply not acceptable in some environments.


AUTHOR

Flavio Poletti polettix@cpan.org


COPYRIGHT AND LICENSE

Copyright (c) 2008-2011 by Flavio Poletti polettix@cpan.org.

This program is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

shortlog
2024-10-06 Flavio PolettiRemove bundling of Path::Classmaster
2024-10-06 Flavio PolettiEvolve to module-based implementation in App
2024-10-04 Flavio PolettiUpdate bundled "quined" version
2024-10-04 Flavio PolettiFix bug in producing list of modules
2023-02-27 Flavio PolettiAdd Module::ScanDeps to the bundled version and cpanfile
2023-02-27 Flavio PolettiAdd bundled version and script to produce it
2023-02-27 Flavio PolettiUpdate and expand licensing
2023-02-27 Flavio PolettiAdd sane .gitignore
2023-02-27 Flavio PolettiDefine useable dependencies
2023-02-27 Flavio PolettiAdd example for 80% of the times
2023-02-27 Flavio PolettiAdd docs for latest feature
2023-02-27 Flavio PolettiAdd feature add-modules-list
2013-03-28 Flavio Polettibumped version
2013-03-28 Flavio Polettislight bugfix in documentation
2013-03-28 Flavio Poletti--unbundle
2012-03-25 Flavio Polettisimplified licensing
...
heads
6 weeks ago master
13 years ago linode