Toolkit(3pm) | User Contributed Perl Documentation | Toolkit(3pm) |
Toolkit - Keep your handy modules organized
This document describes Toolkit version 0.0.2
use Toolkit; # All your favorites are now available
The Toolkit module provides a standard location to store modules that you use all the time, and then loads them for you automatically. For example, instead of always writing:
use strict; use warnings; use Carp; use Smart::Comments;
in every program/module, you can just write:
use Toolkit;
and put all your favorite modules in a file:
> cat $PERL5LIB/Toolkit/Macros/ALWAYS/Modules use strict; use warnings; use Carp; use Smart::Comments;
You can also specify load-on-demand subroutines:
> cat $PERL5LIB/Toolkit/Runtime/prompt use IO::Prompt qw( prompt ); > cat $PERL5LIB/Toolkit/Runtime/say sub say { print @_, "\n" }
in which case Toolkit will install an "AUTOLOAD" that installs these subroutines the first time they're called.
Calling:
use Toolkit;
with no arguments loads any files in the directories:
$PERL5LIB/Toolkit/Macros/ALWAYS/ $PERL5LIB/Toolkit/Macros/DEFAULT/
or any of their subdirectories.
Calling:
use Toolkit qw(foo bar);
any files in the directories:
$PERL5LIB/Toolkit/Macros/ALWAYS/ $PERL5LIB/Toolkit/Macros/foo/ $PERL5LIB/Toolkit/Macros/bar/
or any of their subdirectories.
Using the Toolkit module in any way also installs an "AUTOLOAD" subroutine which looks in:
$PERL5LIB/Toolkit/Runtime/
for a file of the same name as the subroutine that is being autoloaded. That is, if you write:
use Toolkit; baz();
Then the module looks for a file:
$PERL5LIB/Toolkit/Runtime/baz
and executes it in a special namespace. After the file executes, Toolkit expects that the special namespace will now have a subroutine of the required name, which it then calls.
Toolkit uses the following directories and files to configure its behaviour:
Requires:
None reported.
No bugs have been reported.
Please report any bugs or feature requests to "bug-tool-kit@rt.cpan.org", or through the web interface at <http://rt.cpan.org>.
Damian Conway "<DCONWAY@cpan.org>"
Copyright (c) 2005, Damian Conway "<DCONWAY@cpan.org>". All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
2022-10-13 | perl v5.34.0 |