or download this
use threads; #lets us make threads
use threads::shared; #lets us share variables between threads
...
system(call the program); #this will tie up the main thread until it f
+inishes
$job_done = 1; #this should let the thread exit on the next loop
my $error = $watcher->join; #clean up the thread and get it's return.