in reply to Re^8: Execute a sub in the background
in thread Execute a sub in the background

Experts will tell you to use Thread::Queue. I have not much experience with queues. However this is what you can achieve with shared variables:
use threads; use threads::shared; my ($global):shared; my $handler=threads->create(\&handler)->detach; do { print "Enter a value for shared global variable ( x = exit ): ";ch +omp($global=<>); sleep(3); } while($global ne 'x'); sub handler { my $global_old=$global; while(1) { if($global ne $global_old) { print "User changed the global variable to '$global'.\n"; $global_old=$global; } sleep(1); } }