while(1) { pick_batch_of_200(); foreach(1..200) { send_work_to_remote_client($_); ### this I want to fork out here and want to get it done by different process or module so that while loop can proceed with next batch insert_into_db(@work_sent,@result) #### this I want to fork out here and want to get it done by different process or module so that while loop can proceed with next batch } } sub send_work_to_remote_client { #client list foreach(1..20) { connect_random_client_and_Send_work(send_work); } } insert_into_db { #get cached connection insert into XYX values( @result); }