Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the ToolSet CPAN distribution.

Report information
The Basics
Id: 44103
Status: resolved
Priority: 0/
Queue: ToolSet

People
Owner: Nobody in particular
Requestors: joerg [...] joergmeltzer.de
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.99
Fixed in: (no value)



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 {
Subject: Re: [rt.cpan.org #44103] ToolSet doesn't support multiple autouses
Date: Sun, 15 Mar 2009 09:20:09 -0400
To: bug-ToolSet [...] rt.cpan.org
From: David Golden <dagolden [...] cpan.org>
On Fri, Mar 13, 2009 at 12:46 PM, Joerg Meltzer via RT <bug-ToolSet@rt.cpan.org> wrote: Show quoted text
> I have attached a patch for ToolSet v0.99 which changes the underlying > structure from hash to array, allowing multiple autouses.
Joerg, that's a great idea. I was thinking about adding some sort of lazy loading and just changing ToolSet to support autouse is much, much easier. I'll look over the patch and write some tests and see about getting a release out soon. Thank you very much. -- David
Fixed in 1.00