Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-09-19 01:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (129 votes), past polls