descriptionBundle Perl modules inside Perl programs
ownerflavio@polettix.it
last changeMon, 27 Feb 2023 23:39:54 +0000 (28 00:39 +0100)
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
2023-02-27 Flavio PolettiAdd Module::ScanDeps to the bundled version and cpanfilemaster
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
2011-09-07 Flavio PolettiMerge branch 'linode'
2011-09-07 Flavio Polettimerged version in linode with local onelinode
2011-09-07 Flavio Polettiadded -I|--include and inclusion markers
2009-11-24 Flavio PolettiCorrected a bug in the examples
...
heads
14 months ago master
12 years ago linode