my $pid = `ps ax | awk '/programname/ && !/awk/ {print \$1}`; # ;-) #### open my $ps => "ps ax |" or die; my $pid; while (<$ps>) { if (/^\s*(\d+).*\bprogramname\b/) { $pid = $1; last; } } close $ps or die;