#!/usr/pkg/bin/perl -w my $prog = shift || die "no args!\n"; my @pids; open PH, "ps ax|" or die $!; while( ){ !/$0/ && /$prog/ || next; # <-- Change here. /^\s*(\d+)/ and push @pids, $1 } # Try gracefully first, then less so. kill 15, $_ for @pids; sleep 5; kill 2, $_ for @pids; sleep 5; kill 9, $_ for @pids;