Monks, et al.

Been browsing the monk site for awhile now...GREAT HELP! Thanks.
I am all new to Perl, so any help is greatly appreciated. I have several syslog files that I am parsing. Others are done because the fields are static, however, this one is killing me. I open the file and in a while loop, parse each line (till eof). Each line looks like the following (from snort ids):
May 16 11:17:12 system app: [id:id:id] Message [Class] [Priority:] {TCP} 111.1.1.64:1863 -> 222.2.2.155:55527

Here's what I have so far (from trying this and that):
if ($line =~ m/^(\w{3}) \s+ (\d+) \s (\d+\:\d+\:\d+) \s (\S+)\s snort [\[(\d+\:\d+\:\d+)\]]*\:\s+(.+)/ox)

$1 through $4 come out OK, but then $5 scoops up till end of line. (please forgive the poor code)

My problem is I cannot match the variable length field between [id:id:id] and {TCP}. This area will be variable based on {ICMP}, {TCP/UDP}, or error, which I will if statement out when I get this step resolved.

Any help is appreciated.


In reply to Variable Length Parsing by ACiD

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.