Monks,

Ok, I'm stuck. I have a log file in this format:
1;30Nov2001;17:08:25;192.168.1.2;log;accept;;hme0;outbound;udp;192.168 +.86.6;20.248.36.99;domain-udp;1103;63;85;;;;;;;;;;;;;;; 2;30Nov2001;17:08:25;192.168.1.2;log;drop;;hme0;inbound;tcp;63.28.96.2 +54;192.168.11.67;netbios-ssn;18803;48;89;;;;;;;;;;;;;;; 3;30Nov2001;17:08:26;192.168.1.2;log;drop;;hme0;inbound;tcp;65.93.20.2 +23;192.168.26.139;auth;1323;60;89;;;;;;;;;;;;;;; 4;30Nov2001;17:08:26;192.168.1.2;log;drop;;hme0;inbound;tcp;65.93.22.2 +23;192.168.26.139;auth;1323;60;89;;;;;;;;;;;;;;; 5;30Nov2001;17:08:26;192.168.1.2;log;accept;;qfe2;inbound;tcp;192.168. +86.146;20.248.36.97;http;4719;44;85;;;;;;;;;;;;;;; 6;30Nov2001;17:08:26;192.168.1.2;log;accept;;hme0;outbound;tcp;192.168 +.86.146;204.48.36.97;http;4719;44;85;;;;;;;;;;;;;;; 7;30Nov2001;17:08:26;192.168.1.2;log;accept;;qfe2;inbound;tcp;192.168. +86.146;204.48.36.97;http;4721;44;85;;;;;;;;;;;;;;; 8;30Nov2001;17:08:26;192.168.1.2;log;accept;;hme0;outbound;tcp;192.168 +.86.146;24.248.36.97;http;4721;44;85;;;;;;;;;;;;;;; 8;30Nov2001;17:08:26;192.168.1.2;log;accept;;hme0;outbound;tcp;192.168 +.86.146;20.248.36.97;http;4721;44;85;;;;;;;;;;;;;;; 9;30Nov2001;17:08:26;192.168.1.2;log;accept;;qfe2;inbound;tcp;192.168. +27.154;205.18.145.185;http;4396;44;85;;;;;;;;;;;;;;; 10;30Nov2001;17:08:26;192.168.1.2;log;accept;;hme0;outbound;tcp;192.16 +8.27.154;25.188.145.185;http;4396;44;85;;;;;;;;;;;;;;; 11;30Nov2001;17:08:26;192.168.1.2;log;accept;;qfe2;inbound;tcp;192.168 +.27.154;205.88.145.185;http;4397;44;85;;;;;;;;;;;;;;; 12;30Nov2001;17:08:26;192.168.1.2;log;accept;;hme0;outbound;tcp;192.16 +8.27.154;205.188.45.185;http;4397;44;85;;;;;;;;;;;;;;;
And here is the code I have written so far:
#!/usr/bin/perl -w use strict; my $log = './log'; my @data; # Open the firewall log file and create new array containing all of th +e data. open (LOG, $log) or die "Can't open $log: $!"; while (<LOG>){ push (@data, "$_"); } # Split the @data array into separate arrays by category. my (@dst, @service); foreach (@data) { my @lines=split "\n",$_; foreach(@lines){ my ($num,$date,$time,$fw,$type,$action,$alert,$int,$dir,$proto,$sr +c,$dst,$service,$sport,$len,$rule) = (split /;/,$_); push(@dst, $dst); push(@service, $service); } }
This seems to work fine, but what I need to do now is compare the @dst and @service arrays and if the @dst array has the same ip AND the @service array has the same service for at least 50 log entries, then I want to execute a sub, but I can't think of how to do this.

Any suggestions?

TIA

-Dru

Edit kudra, 2001-12-22 Appended to title


In reply to Another Array Problem: comparing. by dru145

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.