Subject: | ToolSet doesn't support multiple autouses |
I am a big fan of your ToolSet module.
I very much like it for writing more compact one-liners with a big and
easily accessible ToolSet.
I also like loading Modules on demand with autouse or Class::Autouse.
Unfortunately the underlying datastructure for ToolSet->export is a
hash, so I can use "autouse" only once in a ToolSet->export.
I have attached a patch for ToolSet v0.99 which changes the underlying
structure from hash to array, allowing multiple autouses.
Subject: | ToolSet.pm.patch |
--- ToolSet.pm 2008-12-04 15:27:15.000000000 +0100
+++ /tmp/ToolSet.pm 2009-03-02 00:39:28.399055200 +0100
@@ -21,9 +21,9 @@
sub export {
my $class = shift;
- my %spec = @_;
+ my @spec = @_;
my $caller = caller;
- $exports_of{ $caller } = \%spec;
+ $exports_of{ $caller } = \@spec;
}
sub import {
@@ -47,7 +47,11 @@
$p->unimport( @{ $no_pragmas{ $class }{ $p } } );
}
}
- while ( my ( $mod, $request ) = each %{ $exports_of{ $class } } ) {
+ my @exports = @{ $exports_of{ $class } };
+ while (@exports){
+ my $mod = shift @exports;
+ my $request = shift @exports;
+
my $evaltext;
if ( ! $request ) {
$evaltext = "package $caller; use $mod";
@@ -76,7 +80,6 @@
*{"${caller}::${fcn}"} = \&{$source};
}
}
-
}
sub set_strict {