i have a script that searchs some files and prints out the lines that contain both of two key words but i only get a print out when i have the case as it is in the file, sometimes these key words are in upper case and sometimes lower case, how can i tell the script to ignore the case.
#!/usr/bin/perl
use strict;
my @files =
(
"mail.log_current",
"mail.log_yesterday",
"mail.log",
"mail.log.0",
"mail.log.1",
"mail.log.2",
"mail.log.3",
"mail.log.4",
"mail.log.5",
"mail.log.6",
"mail.log.7",
);
print "Enter first keyword: ";
my $word1 = <STDIN>; chomp $word1;
print "Enter second keyword: ";
my $word2 = <STDIN>; chomp $word2; #!!!!!
foreach my $file (@files) {
next unless -f $file;
open FILE, $file or die "Can not open $file $!\n";
while (<FILE>) {
print if (/$word1/ and /$word2/);
}
close FILE;
}
thanks,
Start Free Trial