#!/usr/bin/perl -w use strict; use Data::Dumper; use Parallel::ForkManager; my $pm = new Parallel::ForkManager(10); $pm->run_on_finish ( sub { my (undef, $exit_code, $ident) = @_; $update_flag = 1 if $exit_code; } ); my %sess_hist = (); &load_database; for my $session (keys %{$hash{Session}}) { my $pid = $pm->start($session) and next; &run_session($session) if &check_overdue($session); # &run_session updates %sess_hist with new stats else { exit (0); } $pm->finish($session); } $pm->wait_all_children; &save_database if $update_flag;