use strict; my @pslist = ("ps -ef|grep psname=abc","ps -ef|grep psname=def",...,); foreach my $ps(@pslist) { print "Checking for the Process,"; my $ps1 = `$ps`; if($ps1 =~ /psname=abc/) { print "\"abc\" is running Fine\n"; } elsif($ps1 =~ /psnameame=def/) { print "\"def\" is running fine\n"; } elsif($ps1 =~ /psname=xyz/) { print "\xyz\" is running Fine\n"; } else { print "None of the processes are running\n"; } }