pseudocode open (original_file); $counter = 0; while(original_file){ $counter++; } my $peace = $counter/4; # let say the file has an equale number of lines my $count_for_peace = 0; open (file_part); while(original_file){ if ($count_for_peace == $peace){ close file_part_handled; open(file_part_new); $count_for_peace = 0; } print into file_part_handled $count_for_peace++; } my @ch; for(1..4){ my $pid = fork(); if ($pid){ push(@ch,$pid); } elsif($pid ==0){ #read from file 1 and do some processing exit; } else{ die error; } } foreach (@ch){ waitpid($_,0); }