Your regexen look reasonable enough to me. One way to keep your code a little cleaner when you have more than a couple of captures is with the use of the /x modifier and the new-ish named captures:

#!/usr/bin/env perl use 5.014; use warnings; $_ = <DATA>; chomp; /^ (?<mon>\w+)\s(?<dd>\d\d) \s (?<time>..:..:..) # could capture hh:mm:ss separately if need be \s (?<src>\d+\.\d+\.\d+\.\d+) # keep going with your sub-expressions /x; say "time: $+{time} src: $+{src}"; __DATA__ May 20 18:57:27 1.23.25.5 %ASA-6-106100 a6 [local4.info] access-list M +yaccess-Block permitted tcp outside/10.31.0.9(3803) -> inside/10.29.1 +0.91(4127) hit-cnt 1 300-second interval [0xa178b29d, 0x0]

Edit: I note you match dotted-quad IP addresses frequently. If it helps, you can throw that pattern in a variable for re-use:

my $IP_ADDR = qr/\d+\.\d+\.\d+\.\d+/; /...(?<src>$IP_ADDR).../

In reply to Re: A better way to parse this with regexes? Pix ASA logs by rjt
in thread A better way to parse this with regexes? Pix ASA logs by symgryph

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.