foreach my $server (@servers) { $i++; # # fork and background process # our $ME = $0; $ME =~ s|.*/||; our $PIDFILE = $PIDDIR . "/$ME.pid" . $i; my $pid = 0; $daemon{$server} = Proc::Daemon->new ( pid_file => $PIDFILE, work_dir => cwd () ); $pid = $daemon{$server}->Init (); if ($pid == 0) { # do the child stuff } }