I cannot agree with this approach, but sometimes a single file is the easiest 
to distribute.

Currently I am looking at App::Fatpacker - 
https://metacpan.org/pod/App::FatPacker 
<https://metacpan.org/pod/App::FatPacker>

> On 1 Mar 2018, at 15.00, yary <not....@gmail.com> wrote:
> 
> 
> On Thu, Mar 1, 2018 at 9:56 AM, David Cantrell <da...@cantrell.org.uk 
> <mailto:da...@cantrell.org.uk>> wrote:
> 
> My approach is to have the script be mostly a wrapper around more
> easily-testable modules - the script just wrangles arguments and shows
> results.
> 
> +1 for that approach in general. Makes it easy to call the "useful" code in 
> the script in other places.
> 
> Something to do in small scripts which don't aren't module material, is to 
> put all the "useful" code into subs, put the command-line processing & 
> printing into a "sub MAIN", and then have only this top-level statement:
> 
>     exit MAIN unless caller;
> 
> That lets the script be called normally, executing when run from the command 
> line. On the other hand, another perl program can "require 'the_code_file.pl 
> <http://the_code_file.pl/>'" and load all the subs without anything 
> executing- so your test code can call MAIN after setting @ARGV to whatever it 
> wants - or can test the other subs as needed.
> 

Attachment: signature.asc
Description: Message signed with OpenPGP

Reply via email to