matching elements from array and print the results line by line from log file



Hi,
I have a list of element in array that I would like to match the
pattern in logs file. I have hard time take element from array and
matching it. More then weeks now and don't know where to find in man
page. please help me. Here is my code.

#!/usr/bin/perl -w
open ( FILE, " /var/log/cisco.log " ) || die "can't open cisco.log
file!";
@cisco.log = <FILE>;
close (FILE);

@array = qw( BPDUGUARD FAN_FAIL ); # more then 2 elements in array

while (<@cisco.log>){
foreach $line (@array){
$_ =~ $line; #DOESN'T WORK AND I AM STUCK..
print "$_\n"; #WANT TO PRINT THAT MATCH
}
}


__END__
thanks for your help

.



Relevant Pages

  • Re: matching elements from array and print the results line by line from log file
    ... pattern in logs file. ... I have hard time take element from array and ... matching it. ...
    (perl.beginners)
  • Re: Bug in Strings split method???
    ... The limit parameter controls the number of times the pattern is ... applied and therefore affects the length of the resulting array. ... limit n is greater than zero then the pattern will be applied at most n ...
    (comp.lang.java.programmer)
  • Re: Surprise in array concatenation
    ... >> computational states for which A is considered be 1. ... >> memory dump and discover a bit pattern 000000001 at the address FF07712CA0 ... could you stop naming this ADT an array? ... > These are Ada arrays, rock solid low level stuff, based on preexisting ...
    (comp.lang.ada)
  • How to improve performance of regular expression pattern matching
    ... a specific pattern on each line. ... so for each line of the input file the script needs to loop ... through the array until it has either found a pattern stored in the ... I first used the following code to compare the line with the array ...
    (comp.unix.shell)
  • Re: Checking if a list of names appears in a body of text.
    ... an array intersection, but this is problematic for two-word company ... Let's suppose that we aren't interested in where the phrase occurs, or whether it occurs several times, but just whether or not it appears at all. ... So our approach will be to take the original phrase, turn it into a pattern, match the pattern, and return true if the pattern has been matched: ... String strPattern = MakePattern; ...
    (microsoft.public.dotnet.languages.csharp)