use threads; use threads::shared; $dbh = $conn->databaseHandle();# I am calling this from my connection class print "dbh: ". $dbh."\n"; my $done :shared = 0; async { # system 'yourLongRunningCmd'; &long_running_script; $done = 1; }->detach; $dbh->ping while !$done and sleep 15; ## Adjust frequency to suit print "Thread disappears..Done"; exit; sub long_running_script { print "Testing... long_running test is beign called. will sleep for 30 sec\n"; sleep(30); }