[clug] Perl "Preprocessor".

Daniel Pittman daniel at rimspace.net
Wed Feb 25 07:12:53 GMT 2009


Andrew Janke <a.janke at gmail.com> writes:

> Preface: I don't like Perl modules, well OK, actually I like them but
> dont like to distribute perl scripts that require a module to be
> installed to my (generally newbie) users.

That seems reasonable: absent a distribution packaging system[1] it can
be painful to install support code, and telling someone to use CPAN is
an invitation to suffering.

> So is there some nice doo-hoozit that will scan a perl script and
> include the various Modules when it encounters a "use" or the likes?

Yeah, absolutely.  The tool you are after is 'par', which allows you to
package some combination of:

1. Your script and non-core modules in a single script.
2. Your script and all modules, including core, in a single script.
3. Your script, all modules, and the Perl binary, in a single script.

There are some quirks using it, but it generally just works.

Oh, you do need a compatible platform, potentially: you can't (easily)
package Unix scripts on Windows, or Windows scripts on Unix.

Regards,
        Daniel

Footnotes: 
[1]  ...or, I suppose, a package installer like the big commercial
     vendors use.



More information about the linux mailing list