sub getPids{ my ($processName,$owner) = @_; my $ps; my $pid; my $command = "/bin/ps auwwwx | grep $processName | grep -v grep | grep -v 'sh -c' "; $ps = `$command`; # print $ps; my @lines = split( "\n",$ps); # print @lines; foreach my $line (@lines){ # print $line . "\n"; if ($line =~ qr|$owner\s+(\d*)\w+\s+\d+.+processName=$processName|){ $pid = $line =~ qr|$owner\s+(\d*)\w+\s+\d+.+processName=$processName|; say "Found $processName in getPids() owned by $owner. PID is $1"; #print "$1\n"; }else{ say "Loser"; } } } #### if ($line =~ qr|$owner\s+(\w+)\w+\s+\d+.+processName=$processName|){ $pid = $line =~ qr|$owner\s+(\w+)\w+\s+\d+.+processName=$processName|; say "Found $processName in getPids() owned by $owner. PID is $1"; #print "$1\n"; }else{ say "Loser"; }