#!/usr/bin/perl -w use Text::ParseWords; use strict; my (@lines, @fields, @rules, @date, @time, @rearranged); my ($item, $date, $time, $rule); my %count; if($#ARGV <0) { print "usage: cpruleauditor <CheckPoint CSV File> \n"; exit 0; } my $log = $ARGV[0]; open (LOGFILE, "$log") || die "Could not open file: $! \n"; @lines = <LOGFILE>; close (LOGFILE); my $header = $lines[0]; @fields = quotewords(";",0,$header); my $count = 0; validate(); print "Processing file.....please be patient \n\n"; my $value; foreach $value (@fields) { if ($value =~ /rule/) { $rule = $count; } if ($value =~ /date/) { $date = $count; } if ($value =~ /time/) { $time = $count; } $count++; } shift @lines; foreach $item (@lines) { @fields = quotewords(";",0,$item); unless ($fields[$rule] lt 1 ) { push (@rules, $fields[$rule]); } push (@date, $fields[$date]); push (@time, $fields[$time]); } my $enddate = @date - 1; my $endtime = @time - 1; print "The log file covers the period \n"; print "$date[0] $time[0] to $date[$enddate] $time[$endtime] \n\n"; count_rules(@rules); @rearranged = sort{$a <=> $b} keys %count; foreach (@rearranged) { print "rule number \t $_ \t appears \t $count{$_} \t time(s) \n"; } sub validate { if ($fields[0] !~ /num/) { print "The file specified does not appear to be a valid CheckPoint CSV + file \n"; exit 0; } } sub count_rules { map { $count{$_}++ } @rules; return %count; }

In reply to CheckPoint rule auditor by semio

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.