Hello Monks,
I have two questions that I'm seeking guidance with:
1. Is there a way so I do not have to write out each file seprately? For example something like:
my @files = ('d:\log\exported\10Sep2003.elog' ..
'd:\log\exported\17Sep2003.elog')
I know this will not work, but I think you guys will see what I'm trying to do.
2. In the below code, my 'for' loop is not working the way I intended to. It is combining all of the file names into one file and then trying to proceed with the while loop. Here is the error I get when I run this script:
Can not open d:\log\exported\10Sep2003.elog d:\log\exported\11Se
p2003.elog d:\log\exported\12Sep2003.elog d:\log\exported\13Sep2
003.elog d:\log\exported\14Sep2003.elog d:\log\exported\15Sep200
3.elog d:\log\exported\16Sep2003.elog d:\log\exported\17Sep2003.
elog d:\log\exported\22Sep2003.elog: No such file or director
I thought that it would iterate over the first file move onto the while loop and then begin again. Anyone know what I'm doing wrong?
My Script:
use warnings;
use strict;
my $file1 = 'd:\log\exported\10Sep2003.elog';
my $file2 = 'd:\log\exported\11Sep2003.elog';
my $file3 = 'd:\log\exported\12Sep2003.elog';
my $file4 = 'd:\log\exported\13Sep2003.elog';
my $file5 = 'd:\log\exported\14Sep2003.elog';
my $file6 = 'd:\log\exported\15Sep2003.elog';
my $file7 = 'd:\log\exported\16Sep2003.elog';
my $file8 = 'd:\log\exported\17Sep2003.elog';
my $file9 = 'd:\log\exported\22Sep2003.elog';
my @files = qq($file1 $file2 $file3 $file4 $file5 $file6 $file7
$file8 $file9);
my ($fw, $rule1, $dst);
for (@files){
open (FILE, $_) or die "Can not open $_: $!\n";
while (<FILE>){
($fw, $dst, $rule1) = (split /;/)[3,11,15];
print if ($fw =~ /192\.168\.15\.1/) &&
($dst =! /192\.168\.31\.25/) && ($rule1 =~ /\b12\b/);
}