#$Q_found->enqueue( $cmd ) ; # using this in place of async works #### c:\test>junk9 Create terminal watcher... Awaiting commands... fred fred bill bill john john quit Resolving open threads #### #!/usr/bin/perl use strict; use warnings; use threads; use Thread::Queue; # Create terminal watcher print "Create terminal watcher...\n"; my $Q_stdin = Thread::Queue->new; async { $Q_stdin->enqueue( $_ ) while defined( $_ = ); }->detach; my $Q_found = Thread::Queue->new; my $cmd; print "Awaiting commands...\n"; MAIN_LOOP: while (not defined $cmd or $cmd !~ /^q/i) { sleep(1); # Reduce load # Process commands $cmd = $Q_stdin->dequeue_nb; if (defined $cmd) { chomp $cmd; if ($cmd =~ /^q/i) { print "Resolving open threads\n"; } else { async { $Q_found->enqueue( $cmd ) ; }->detach; #$Q_found->enqueue( $cmd ) ; # using this in place of async works } } # Print announcements while (defined(my $output = $Q_found->dequeue_nb)) { print ">$output\n"; } } __END__ c:\test>junk9 Create terminal watcher... Awaiting commands... fred bill john >fred mary >bill quit >john Resolving open threads >mary #### c:\test>perl -wle" printf qq[%08d\n], $_ for 1 .. 10; print 'quit' " | perl junk9.pl Create terminal watcher... Awaiting commands... >00000001 >00000002 >00000003 >00000004 >00000005 >00000006 >00000007 >00000008 >00000009 Resolving open threads >00000010