Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

cleverett's scratchpad

by cleverett (Friar)
on Mar 08, 2010 at 20:41 UTC ( #827429=scratchpad: print w/replies, xml ) Need Help??

sub produce { my ( $pkg, @args ) = @_; my %args = %{ {@args} }; my $type = delete $args{type} || q{}; my %attr = %{ delete $args{attrs} || {} }; my ( $item_module, $item_class ) = $pkg->find_product( $type, %att +r ); if ( !exists $already_required{$item_class} ) { ## compile inside eval, so we get a real error message at leas +t once local $EVAL_ERROR = q{}; my $is_compiled = eval { require $item_module; return 1; }; if ( !$is_compiled ) { $EVAL_ERROR ||= 'Unknown error'; confess "$item_module didn't compile: $EVAL_ERROR"; } # track already compiled classes my @parents; { no strict 'vars'; *parents = *{"$item_class\::ISA"}{ARRAY}; } foreach my $p (@parents) { next if ! $p =~ m/^TDP::/; $already_required{$p} = ++$counter } $already_required{$item_class} = ++$counter; } return $item_class->new(%args); }
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2016-12-04 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (64 votes). Check out past polls.