HI ,
I have to get only error messages and warnings text form
"/var/log/messages".
I wrote below code for to get only "warnings, error and caution " messages
from a file.
but grep command wont work. because I have to pass scalar variable to
search.
#!/usr/bin/perl
use warnings;
use strict;
open (FH , "< /var/log/messages");
my @search = qw( warnings errors Caution);
my @file = <FH>;
close FH;
foreach (@file)
if(grep(/^...@search/,$_)){
print $_;
}
}
please help me to get only search string. optimised code.
--Thanks in advance.
-Mahesh