use Thread qw(yield async); async { my $time = 10; while ($time--){$command = `shell command`;} yield; }; #do something with command