1. You have a variable @global. This is a bad thing. Name it something useful.
  2. You do an insert explicating $writer[0] through $writer[24]. join would make this cleaner.
  3. qw is your friend. For example,
    @snort =("large","packet","bad","traffic","inbound","attempt","web", +"IIS","cmd.exe","cgi","access","multiple","decode");
    becomes
    @snort = qw(large packet bad traffic inbound attempt web IIS cmd.exe cgi access multiple decode);
  4. You should die after you cannot connect to the database.
  5. Use multi-dimensional arrays, or, better, hashes of arrays. That way, your use of @watcher doesn't require split. Something like
    my @watcher = ( \@pix, \@denies); ... my @global = @{$watcher[$i]};
  6. Where do you use $global? (Using warnings would've caught this...)
  7. if($global[$x]=~/ZSP/i){ @ret=split(/ZSP/,$global[$x]); $global[$x]=""; $global[$x]=join(' ',@ret); }
    should be (before using references correctly...)
    if (my @ret = split /ZSP/, $global[$x]) { $global[$x] = join ' ', @ret; }
  8. Something like the following might help ...
    foreach my $r (@spy) { if($input =~ /$r/i){ $findings .= ' ' . $r; $fn++; } }
And, there's plenty more where that came from. The most important thing I can say is that your data structures drive your logic, especially in an application like this. Improve your understanding of data structures and your code will be that much easier. Every hour you spend on learning and mastering data structures will translate to a week saved in coding, if you code seriously for a year. That's not an exagerration, either.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.


In reply to Re: Clean Code - What a mess... by dragonchild
in thread Clean Code - What a mess... by PyroX

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.