use MCE::Flow max_workers => 8; my $file1 = "/path/to/file1.txt"; my $file2 = "/path/to/file2.txt"; unlink $file1 if -e $file1; unlink $file2 if -e $file2; mce_flow sub { my $wid = MCE->wid; if (MCE->wid % 2 == 0) { MCE->sendto("file:$file1", "sunny day from $wid\n"); } else { MCE->sendto("file:$file2", "raining day from $wid\n"); } };