Try if (/\bUP\b/ && /$server_name/) You are not matching on $server_name as $server_name is not enclosed by the match operator. You could easily put this in a single regular expression if the position of $server_name is predictable. e.g. It alway falls after UP.
If you cannot predict where the server name falls then it will be more efficient to put the text that occurs least frequently on the left of the && as the right-hand side is only evaluated if the left-hand expression returns true. Steve Aaron -----Original Message----- From: Craig Sharp [mailto:[EMAIL PROTECTED]] Sent: Monday, November 26, 2001 12:45 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: [Perl-unix-users] Script Help Please Hi all, I am lost. I have the following script that opens the log file WUGEvent.log and looks for the statment "UP", replaces spaces and writes out the new log file. It works great! Here is the problem. I need to read in another file (wuglist.txt) containing a list of server names and then compare each name to the line currently being processed. Then if it matches, write the line out to a new file following the conversion. I tried to read the server name from the file into a variable and add a && to the reg expression looking for UP but it did not work: if (/\bUP\b/ && $server_name) I am lost in how to setup the loop and compare. Thanks, Here is the script and sample log files: #!/usr/bin/perl #--------------------------------------------------------------------------- ----------- # log_convert.pl script #--------------------------------------------------------------------------- ----------- open (inlogfile, "WUGEvent.log") || die "$!\n"; open (outlogfile, ">newlog.log") || die "$!\n"; @lines = <inlogfile>; select outlogfile; foreach (@lines) { chomp; if (/\bUP\b/) { s/\t+/|/g; s/missed //g; print "$_\n"; } } close inlogfile; close outlogfile; —--------------------------------------------------------------------------- --------- Sample WUGEvent.log 20011022 143423 C:\Program Files\WhatsUp\b31.wup Alert successful process N:roush_31 F:768 A:SMTPMail/Derrick (pager) 20011022 143430 C:\Program Files\WhatsUp\B07.wup Alert successful process N:roushftp1 F:768 A:SMTPMail/Craig's e-mail 20011022 143430 C:\Program Files\WhatsUp\B07.wup Alert successful process N:roushftp1 F:768 A:SMTPMail/Craig's pager 20011022 143430 C:\Program Files\WhatsUp\B07.wup Alert successful process N:roushftp1 F:768 A:SMTPMail/Dave's pager 20011022 143431 C:\Program Files\WhatsUp\B07.wup Alert successful process N:roushftp1 F:768 A:SMTPMail/Help Desk 20011022 143514 C:\Program Files\WhatsUp\b31.wup UP roush_31 10.31.1.1 missed 4 20011022 143515 C:\Program Files\WhatsUp\b31.wup Alert successful process N:roush_31 F:768 A:SMTPMail/Beryl (e-mail) 20011022 143515 C:\Program Files\WhatsUp\b31.wup Alert successful process N:roush_31 F:768 A:SMTPMail/Bethany (e-mail) 20011022 143516 C:\Program Files\WhatsUp\b31.wup Alert successful process N:roush_31 F:768 A:SMTPMail/Dale (e-mail) 20011022 143516 C:\Program Files\WhatsUp\b31.wup Alert successful process N:roush_31 F:768 A:SMTPMail/Derrick (e-mail) 20011022 143516 C:\Program Files\WhatsUp\b31.wup Alert successful process N:roush_31 F:768 A:SMTPMail/Help Desk 20011022 143517 C:\Program Files\WhatsUp\b31.wup Alert successful process N:roush_31 F:768 A:SMTPMail/Dave's pager 20011022 143517 C:\Program Files\WhatsUp\b31.wup Alert successful process N:roush_31 F:768 A:SMTPMail/Derrick (pager) 20011022 143524 C:\Program Files\WhatsUp\B07.wup UP roushftp1 208.44.92.201 missed 4 20011022 143525 C:\Program Files\WhatsUp\B07.wup Alert successful process N:roushftp1 F:768 A:SMTPMail/Craig's e-mail 20011022 143525 C:\Program Files\WhatsUp\B07.wup Alert successful process N:roushftp1 F:768 A:SMTPMail/Craig's pager 20011022 143526 C:\Program Files\WhatsUp\B07.wup Alert successful process N:roushftp1 F:768 A:SMTPMail/Dave's pager 20011022 143526 C:\Program Files\WhatsUp\B07.wup Alert successful process N:roushftp1 F:768 A:SMTPMail/Help Desk 20011022 144058 C:\Program Files\WhatsUp\B09.wup DOWN roush_ap 199.179.57.7 Host Unreachable —--------------------------------------------------------------------------- ---- Sample newlog.log 20010930 042501 C:\Program Files\WhatsUp\B07_NT.wup UP liv7-app1 200.1.1.18 2 20010930 042501 C:\Program Files\WhatsUp\B07_NT.wup UP liv7-app5 200.1.1.15 2 20010930 042501 C:\Program Files\WhatsUp\B07_NT.wup UP liv7-app2 200.1.1.12 2 20010930 042701 C:\Program Files\WhatsUp\B07_NT.wup UP liv-acct 200.1.1.11 3 20010930 182519 C:\Program Files\WhatsUp\b41.wup UP fsnsusan 10.41.1.1 1 20010930 182519 C:\Program Files\WhatsUp\b41.wup UP rsg01 10.41.1.10 1 20010930 182519 C:\Program Files\WhatsUp\b41.wup UP chaplin1 10.41.1.12 1 20010930 182519 C:\Program Files\WhatsUp\b41.wup UP ECOMMERC 10.41.1.11 1 —--------------------------------------------------------------------------- -- Sample wuglist.txt machine_6 roush_app2 roush_liv7 roush_acct roush_mail3 roush_domain msnharry roush_dhcp1 fs05431 roush_ap fsnkelly fsntammy fsnralph roush_31 fsnjacob Craig A. Sharp Unix Systems Administrator DNS Administrator Roush Industries Office: 734-779-7282 Cell: 734-231-6769 Fax: 734-779-7807 [EMAIL PROTECTED] ==================================================== I have not lost my mind, it's backed up on tape somewhere! ==================================================== _______________________________________________ Perl-Unix-Users mailing list. To unsubscribe go to http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users