my $job = do { lock (@jobstack); extract_job(\@jobstack); # this will find the next one to do, and remove it from the list, and return it };