description | Bundle Perl modules inside Perl programs |
owner | flavio@polettix.it |
last change | Sun, 6 Oct 2024 13:11:35 +0000 (6 15:11 +0200) |
URL | git://repo.or.cz/mobundle.git |
https://repo.or.cz/mobundle.git | |
push URL | ssh://repo.or.cz/mobundle.git |
https://repo.or.cz/mobundle.git (learn more) | |
bundle info | mobundle.git downloadable bundles |
content tags |
mobundle - bundle modules inside your scripts
Ask the version number to the script itself, calling:
shell$ mobundle --version
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]
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
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:
this is where you should put your shabang and the use
s 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.
this part is generated automatically based on your instructions about which modules should be bundled.
this is the body of your script, i.e. what your script is supposed to do.
It will likely contain either use
s or require
s that need the modules
that are bundled in the modules
section.
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
either you're willing to bundle the interpreter as well, in which case PAR (or, better, pp) will generate a super-executable bundling all necessary stuff
or you have to be sure that PAR is installed in the target directory.
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.
Flavio Poletti polettix@cpan.org
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.
6 weeks ago | master | logtree |
13 years ago | linode | logtree |