The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 04-28-2008
meevagh meevagh is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 7
PERL: Searching for a string in a text file problem

Looking for a bit of help. I need to search for a string of words, but unfortunately these words are located on separate lines.

for example the text output is:

United
Chanmpions
Ronaldo
Liverpool
Losers
Torres


and my script code is

print("DEBUG - checking file message");
while (<FILE>){
$line = $_;

if($line =~ /United/ ){
print("\nAbout to send email\n");
sendEmail($contacts,
"",
"Monitoring",
"\nPlease be aware that there is a problem.",
"",
"");
}

the above script will send out an e-mail when it locates United, but I need to send out an e-mail when it gets United Champions Ronaldo.

I thought something like
if($line =~ /United/n Champions/n Ronaldo/)

But no luck.

Any suggestions as to how to go about this.