matching elements from array and print the results line by line from log file
- From: mmlkkl6768@xxxxxxxxx (slow_leaner)
- Date: Tue, 28 Oct 2008 10:58:38 -0700 (PDT)
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
.
- Follow-Ups:
- Re: matching elements from array and print the results line by line from log file
- From: "John W. Krahn"
- RE: matching elements from array and print the results line by line from log file
- From: Andy Cravens
- Re: matching elements from array and print the results line by line from log file
- Prev by Date: HoH to AoA
- Next by Date: Re: Curly braces and the logic of PERL
- Previous by thread: HoH to AoA
- Next by thread: RE: matching elements from array and print the results line by line from log file
- Index(es):
Relevant Pages
|