Register a domain and help support LQ
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


Closed Thread
  Search this Thread
Old 08-10-2010, 03:38 AM   #1
Registered: Aug 2010
Posts: 50

Rep: Reputation: 0
Use of uninitialized value in pattern match (m//)

> I am running the following code and receiving the warning :
> Use of uninitialized value in pattern match (m//) at line 38

#!/usr/bin/perl -w
#written by trizsolo
#usage: ./ args args args
#you can add as many processes as needed for args
#or use the defaults... syslogd is always checked
my $user='root';
my $host=`hostname`;
my $date=`date`;
my $logfile="$host" . '.log';
our @proc_list=@ARGV;
# Default list of processes
if(@proc_list==0){ # check for arguments
@proc_list=('inetd', 'sendmail', '');
push(@proc_list, 'syslogd'); # add syslogd to check

# ---------- open logfile and determine Operating System --------------
open(LOG, ">>$logfile") or die "Can't open $logfile to write: $!";
print LOG "Searching for: @proc_list on $date!\n";
chomp($os=`uname -r`);
print LOG "OS on this server is $os\n";

# ---------------- call "ps" & analyse output --------------------
foreach my $process (@proc_list) {
$event_count{$process} = 0;
open(PS, "/bin/ps auwx |") or die "Can't run ps: __FILE__ $!";
$/="\n"; # record seperator
) {
foreach my $process(@proc_list) {
if($_ =~(m/$process/i)) {
open(LOG,">>$logfile") or die "Cannot open $logfile: $!";
# Add line to log to nagios if needed
foreach $process(@proc_list) {
if($event_count{$process} ==0) {
print LOG "Process $process is NOT running!\n";
system("/bin/logger -p warn Process: $process is NOT running!\n")
== 0 or die "Cannot complete cmd: $! : $?";
print LOG "Process $process occurred $event_count{$process} times!\n";
exit 0;

please help
Old 08-10-2010, 03:53 AM   #2
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295

Please stick to one thread per problem/question. Double posting will not help you any faster but on the other hand will confuse you a lot more. Stick to your first thread discussing the same problem/question, where users have already posted and keep the conversation in one place please.

Kind regards,

Old 08-10-2010, 02:07 PM   #3
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,047
Blog Entries: 11

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Match pattern and replace sol_nov Programming 7 11-30-2009 09:23 PM
[SOLVED] Adding (not replacing) a pattern match with a similar pattern? b-bri Linux - Newbie 2 08-31-2009 01:36 AM
printing pattern match and not whole line that matches pattern Avatar33 Programming 13 05-06-2009 07:17 AM
pattern match : korn shell tostay2003 Programming 1 12-31-2008 01:08 PM
perl pattern match question lluciano Programming 4 02-28-2006 06:59 AM

All times are GMT -5. The time now is 09:53 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration