On 11/30/12 23:05, Michael G Schwern wrote:
On 2012.11.30 6:04 PM, David Christensen wrote:
I want one file that can be used:
1.  As a module (*.pm) and as a script (executable *.pl, or just executable
base name with no extension) on machines where I want to install Perl modules;
and
2.  As a stand-alone script on machines where I don't want to install Perl
modules.
To solve 1 I would suggest doing what most of the App::* modules do.  Put all
the logic into the .pm file and make the program a thin wrapper around it.
App::Ack for example.  https://metacpan.org/release/ack  This is far simpler
to write for, use and test.
For 2 you can use App::Fatpacker to generate the stand alone version.  This is
what cpanminus does.  The advantage is you are not limited to a single .pm
file and it handles dependencies.
https://metacpan.org/module/App::FatPacker
https://metacpan.org/source/MIYAGAWA/App-cpanminus-1.5018/bin/cpanm

ack and fatpack -- those look useful.  :-)


The "ack" source distribution includes a Makefile.PL with an overloaded MY::postamble() that creates a rule to generate the "ack" script from the "ack-base" script, one non-core Perl module (File::Next), and several distribution modules using the included "squash" script. I built the distribution, copied the "ack" script to another machine with Perl and without App::Ack or File::Next, and "ack" seems to work. So, it demonstrates both wish list items.


"fatpack" seems to serve a similar function as ack's "squash".


Cava Packager is an option for distributing scripts to machines that don't have Perl:

    http://www.cava.co.uk/


Thanks!


David

Reply via email to