foreach (keys %plugins) { my $thread_queue = Thread::Queue::Any->new; my @thread_subs; $plugins{$_}->SUBS_AS_THREADS(\@thread_subs, $thread_queue); foreach my $sub (@thread_subs) { async { $sub->($plugins{$_}, \%plugins, $thread_queue, $mw) }; } } ... ... MainLoop;