Discussion:
How do I arrange for Makefile.PL to create a modulino instance script?
(too old to reply)
David Christensen
2012-08-25 23:04:04 UTC
Permalink
makemaker:

I am working on a modulino [1] and would like to use ExtUtils::MakeMaker
to generate a Makefile such that "make" (or "make all) copies the module
file (lib/MyModulino.pm) to a script file (perl-bin/mymodulino.pl) and
sets the execute bit.


Any suggestions?


TIA,

David



References:

[1] d foy, brian, 2007, "Mastering Perl", O'Reilly Media,
http://shop.oreilly.com/product/9780596527242.do
David Christensen
2012-12-01 02:04:27 UTC
Permalink
I'm not sure why you'd want to turn a .pm file into a program.
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.


David
David Christensen
2012-12-01 18:54:05 UTC
Permalink
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

Loading...