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/); }

In reply to Range of File Names and For/While Problem by Dru

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.