in reply to A better way to parse this with regexes? Pix ASA logs

What is that syntax? See perlfaq6#How can I hope to use regular expressions without creating illegible and unmaintainable code?

write something like this (incomplete examples)
for perl 5 and up
my $re_asalog = qr{ ^ (.{15}) # $1 timestamp \s (\S+) # $2 firewall \s (\S+) # $3 part firewall access-list \s+ (\S+) # $4 source acl \s+ (\S+) # $5 action ... }xm;
for perl-5.10 and up
my $re_asalog = qr{ ^ # start of line (?<time> .{15} ) \s \s (?<firewall> \S+ ) \s (?<part_firewall> \S+ ) \s access-list \s (?<source_acl> \S+ ) \s (?<action> \S+ ) \s (?<protocol> \S+ ) \s (?<source_interface> \S+ ) \s (?<source_ip> \S+ ) \s (?<source_port> \S+ ) # ... $ # end of line }mx;

running example using named capture buffers instead of numbered ones , See perlvar#% , perlre#(?<NAME>pattern) , and #(DEFINE)

#!/usr/bin/perl -- use Data::Dump ; use 5.010; use re 'debug'; $_=1234; m{ (?<P>(?&V)) # match <V> and save to $+{P} (?<Q> .) # match <Q> and save to $+{Q} # this can be saved in $v_definition = qr// (?(DEFINE) (?<V> ...) # <V> aka (?&V) is three chars ) }xm; dd\%+ __END__ Compiling REx "%n (?<P>(?&V)) # match <V> and save to $+{P} %n (?<Q +> .) "... synthetic stclass "ANYOF{i}[\x00-\x09\x0b-\xff][{non-utf8-latin1-all}{ +unicode_all}]". Final program: 1: OPEN1 'P' (3) 3: GOSUB3[+14] (6) 6: CLOSE1 'P' (8) 8: OPEN2 'Q' (10) 10: REG_ANY (11) 11: CLOSE2 'Q' (13) 13: DEFINEP (15) 15: IFTHEN (27) 17: OPEN3 'V' (19) 19: REG_ANY (20) 20: REG_ANY (21) 21: REG_ANY (22) 22: CLOSE3 'V' (27) 24: LONGJMP (26) 26: TAIL (27) 27: END (0) stclass ANYOF{i}[\x00-\x09\x0b-\xff][{non-utf8-latin1-all}{unicode_all +}] minlen 4 Matching REx "%n (?<P>(?&V)) # match <V> and save to $+{P} %n (?<Q> + .) "... against "1234" Matching stclass ANYOF{i}[\x00-\x09\x0b-\xff][{non-utf8-latin1-all}{un +icode_all}] against "1" (1 bytes) 0 <> <1234> | 1:OPEN1 'P'(3) 0 <> <1234> | 3:GOSUB3[+14](6) 0 <> <1234> | 17: OPEN3 'V'(19) 0 <> <1234> | 19: REG_ANY(20) 1 <1> <234> | 20: REG_ANY(21) 2 <12> <34> | 21: REG_ANY(22) 3 <123> <4> | 22: CLOSE3 'V'(27) EVAL trying tail ... 0 3 <123> <4> | 6: CLOSE1 'P'(8) 3 <123> <4> | 8: OPEN2 'Q'(10) 3 <123> <4> | 10: REG_ANY(11) 4 <1234> <> | 11: CLOSE2 'Q'(13) 4 <1234> <> | 13: DEFINEP(15) 4 <1234> <> | 15: IFTHEN(27) 4 <1234> <> | 27: END(0) Match successful! { # tied Tie::Hash::NamedCapture P => 123, Q => 4, } Freeing REx: "%n (?<P>(?&V)) # match <V> and save to $+{P} %n (?<Q> + .) "...