Dru has asked for the wisdom of the Perl Monks concerning the following question:
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:
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:
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:
I know this will not work, but I think you guys will see what I'm trying to do.my @files = ('d:\log\exported\10Sep2003.elog' .. 'd:\log\exported\17Sep2003.elog')
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:
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?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
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/); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Range of File Names and For/While Problem
by jeffa (Bishop) on Sep 22, 2003 at 19:34 UTC | |
Re: Range of File Names and For/While Problem
by Enlil (Parson) on Sep 22, 2003 at 19:38 UTC | |
Re: Range of File Names and For/While Problem
by svsingh (Priest) on Sep 22, 2003 at 19:47 UTC | |
by svsingh (Priest) on Sep 22, 2003 at 20:41 UTC | |
by demerphq (Chancellor) on Sep 22, 2003 at 21:57 UTC |
Back to
Seekers of Perl Wisdom