37 "pattern=s" => \@fn_patterns, |
37 "pattern=s" => \@fn_patterns, |
38 "top=s" => \$top, |
38 "top=s" => \$top, |
39 "parsed=s" => \$fn_parsed, |
39 "parsed=s" => \$fn_parsed, |
40 "failed=s" => \$fn_fail, |
40 "failed=s" => \$fn_fail, |
41 "debug=i" => \$DEBUG, |
41 "debug=i" => \$DEBUG, |
42 "retrace!" => \$re_trace, |
|
43 "help" => \$help, |
42 "help" => \$help, |
44 ) or die "error in command line arguments"; |
43 ) or die "error in command line arguments"; |
45 |
44 |
46 if( $help ) { |
45 if( $help ) { |
47 my $VER = '$Id: perlgrok.pl,v d6e64daafdc1 2021/09/29 23:46:59 grin $'; |
46 my $VER = '$Id: perlgrok.pl,v 87c55c058b6a 2021/09/30 14:00:47 grin $'; |
48 print "$0 $VER (c) Peter 'grin' Gervai, 2021\n\n"; |
47 print "$0 $VER (c) Peter 'grin' Gervai, 2021\n\n"; |
49 print "Usage: $0 [--input input_file] [--pattern pattern_file] [--pattern another] [--top final_macro] \n"; |
48 print "Usage: $0 [--input input_file] [--pattern pattern_file] [--pattern another] [--top final_macro] \n"; |
50 print " [--parsed parsed_outfile] [--failed failed_lines_file] [--debug n] [--noretrace] [--help]\n"; |
49 print " [--parsed parsed_outfile] [--failed failed_lines_file] [--debug n] [--help]\n"; |
51 print " input: input file to be processed; default stdin\n"; |
50 print " defaults are stdin, stdout, 'patterns' as patternfile and 'TEST' as final macro.\n\n"; |
52 print " pattern: input grok-style pattern file; default patterns (name space pattern) (multiple possible)\n"; |
|
53 print " top: name of the pattern to match; default TEST\n"; |
|
54 print " parsed: output filename for parsed data; default stdout\n"; |
|
55 print " failed: output filename for lines not matched; default none\n"; |
|
56 print " debug: debug level 0 (none), 1 (error), 3 (warning), 7 (debug), 9 (trace)\n"; |
|
57 print " notrace: disable regexp syntax check per pattern\n"; |
|
58 print "\n\n"; |
|
59 exit; |
51 exit; |
60 } |
52 } |
61 |
53 |
62 if( $#fn_patterns < 0 ) { |
54 if( $#fn_patterns < 0 ) { |
63 push @fn_patterns, "patterns"; |
55 push @fn_patterns, "patterns"; |
174 $input{$key} = $data; |
166 $input{$key} = $data; |
175 &d(7, "RESOLVED '$key'! Result=/$data/"); |
167 &d(7, "RESOLVED '$key'! Result=/$data/"); |
176 |
168 |
177 if( $re_trace ) { |
169 if( $re_trace ) { |
178 # die if regexp is bad |
170 # die if regexp is bad |
179 "abc" =~ /$data/; |
171 my $test = qr($data); |
180 } |
172 } |
181 |
173 |
182 # release loop protection for $key |
174 # release loop protection for $key |
183 delete $processing{$key}; |
175 delete $processing{$key}; |
184 } |
176 } |