use Time::HiRes qw(usleep); use File::Spec; # this should be near, if not combined with, the @urls list to encourage keeping them in sync # which is far better than doing this in a separate file! # (you may be able to even just use the @urls array to generate this list, even better!) my @sites = qw( /path/to/site/one /path/to/other/site ); sub fastcgi_restart { system qw(pkill fcgi); usleep(500); system qw(pkill -9 fcgi); for (@sites) { # probably should pick a unique name for the socket somehow, but I'll leave that # to you - I'm just copying your code here. system File::Spec->catfile($_, 'fastcgi.pl'), qw(-l /tmp/mysite.socket -n 3 -d); } }