HOWTO: Running multiple processes in a single Perl script using POE

The perl module POE is best known for simulating multiple user threads in a perl application.

POE is also very useful for managing the forking and managing of child processes.  By using POE to handle this, the programmer can stop worrying about correctly handling the forking.

Set the number of child processes with MAX_CONCURRENT_TASKS.  For example, to allow for three child processes that do the work:

sub MAX_CONCURRENT_TASKS () { 3 }

The child process executes the do_stuff() function, so put whatever you need to run in parallel there.

Continue reading “HOWTO: Running multiple processes in a single Perl script using POE”

Share Button