mascip has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
I am fairly new to Perl and will probably say naive and incorrect things in this message.

From what i understood, the Toolkit module (that i have just tried yesterday for the first time) enables to replace a long list of "use" lines by

use Toolkit

It is especially nice because it can determine whether some functions are used or not in the code, and "use" them only if this is the case.

This seems really great, but
to use it, you have to write the list of used modules in several "configuration" files that you put in different parts of the $PERL5LIB/Toolkit directory.
This seems to make it slightly complicated to install a module that uses Toolkit on a new computer, as you will have to copy all the "configuration" files in the right place.

Ok, it is not THAT complicated. But it would be nice if it wasn't needed.
Please, tell me if what i said make sense, or if there is something i didn't understand about the Toolkit module.

Two naive ideas : it could be nice if...

1. the Toolkit module could save this list of modules somewhere, carry it around, and install them wherever i will install my module. I don't imagine at all how to do this, though.

2. the Toolkit module could be "switched off" by adding the 'switch off' argument

use Toolikt 'switch off'
which would comment the
# use Toolikt 'switch off'
line, and add the list of used modules and functions underneath.

Thus, the developers of a particular module could use Toolkit during development, and "switch if off" before releasing their module, which would simply replace the "use Toolkit" line by the appropriate lines, for each .pl and .pm file (as they don't all use the same modules and functions).

Or, (2 bis) Toolkit could be distributed with a script that would enable to do this for all source using Toolkit in a directory.

Does this make any sense ? If not, i'll be happy to learn something about how to use Toolkit properly :-)

Replies are listed 'Best First'.
Re: ideas to improve the Toolkit module ?
by davido (Cardinal) on Feb 27, 2012 at 13:59 UTC

    You may find the following modules to be interesting reading (and to mostly duplicate the functionality you're contemplating in "1.")

    • MyCPAN::App::DPAN -- A tool that will let you create a personal (and even portable) repository of distributions for easy install using cpan
    • Task -- A more flexible replacement for Bundle::
    • Carton -- Another bundling option.
    • scriptdist -- Create a distribution for a Perl script.

    I think what you're after has already been done, if what you're after is a means of creating a portable bundle that can be used to install a toolchain. It's just disguised behind the dpan, and Task names.


    Dave

Re: ideas to improve the Toolkit module ?
by toolic (Bishop) on Feb 27, 2012 at 13:21 UTC
    Something to consider, from Categorized Damian Modules, Toolkit is classified as...
    Damian modules that are specifically debugging and coding aids and which Damian uses himself during code development:
Re: ideas to improve the Toolkit module ?
by ww (Archbishop) on Feb 27, 2012 at 13:25 UTC
    ++ for enthusiasm. Your reward? Observations I hope you find helpful:

    CPAN tells us that the doc is version 0.0.2 (suggesting that further development is anticipated)... and provides the author's email. Perhaps you should pass on your ideas... and an offer of help... to Damian Conway.

    But reading that doc makes it very clear that there are several judgements the user has to make in determining what to include in the /ALWAYS/ macro... and the on-demand sections. So re-reading the whole doc might be a good place to start.

    As to "carrying (it) around," you may find interesting results in a search on "Perl on a stick" or "(Perl && thumbdrive)" (sorry, I forget which, and I've really got to leave you something to burn off some energy). cheers. ww

Re: ideas to improve the Toolkit module ?
by tobyink (Canon) on Feb 27, 2012 at 18:02 UTC

    Still at a fairly early stage of development, but check out my module Syntax::Collector. The idea is that you create a module like this:

    package MASCIP::Stuff::A; our $VERSION = 1; use Syntax::Collector -collect => q{ use common::sense 3.0 ; use Data::Dumper 0 qw/Dumper/; use IO::All 0 qw/io/; }; 1;

    And then when you are writing code, just do:

    use MASCIP::Stuff::A 1;

    ... and Syntax::Collector will magically enable everything for you.

    The advantage of Syntax::Collector over other modules that do the same thing is this. Grepping through your source code for lines that match /^use/ will reveal the pre-requisites. Most other module bundling techniques tend to obscure which actual modules are being used, which can make automatically determining pre-requisites difficult.

Re: ideas to improve the Toolkit module ?
by duelafn (Parson) on Feb 27, 2012 at 20:52 UTC

    #1. This sounds like a job for git or other Version Control System (though not svn - see bug report)

    #2. I think the script idea sounds better where toolkit.pl --off lib recursively descends through lib and makes the changes toolkit.pl --on lib undoes it. Code it up and submit a patch!

    Though, personally, I find emacs-template (or whatever templating your editor supports) a superior approach to the whole idea.

    Good Day,
        Dean

      Wow, thank you for so many interesting answers !

      I realized today that i don't really need something so evolved right now, and am in a 10 days rush. But it's an idea i'm interested in, so i will probably come back to it in the weeks /months to come.

      I will probably go through your proposed solutions and write an overview of what the different methods say they do and don't do. Unless if someone did that before me : i can always hope !

      If i realized that one of my naive ideas was worth some programming hours (but i guess one of your proposed solution will do better than me), i would probably produce something. Feel free to do it before my if you wanted to : i would be please to use the result =o)