perlgrok.pl
changeset 10 72f6df1085b7
parent 9 f1cb959b4603
child 11 5c38653bd7e7
--- a/perlgrok.pl	Thu Sep 30 15:38:43 2021 +0200
+++ b/perlgrok.pl	Thu Sep 30 16:01:20 2021 +0200
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# $Id: perlgrok.pl,v d6e64daafdc1 2021/09/29 23:46:59 grin $
+# $Id: perlgrok.pl,v 87c55c058b6a 2021/09/30 14:00:47 grin $
 #
 # grok parser in perl
 #
@@ -39,23 +39,15 @@
     "parsed=s"      => \$fn_parsed,
     "failed=s"      => \$fn_fail,
     "debug=i"       => \$DEBUG,
-    "retrace!"      => \$re_trace,
     "help"          => \$help,
 ) or die "error in command line arguments";
 
 if( $help ) {
-    my $VER = '$Id: perlgrok.pl,v d6e64daafdc1 2021/09/29 23:46:59 grin $';
+    my $VER = '$Id: perlgrok.pl,v 87c55c058b6a 2021/09/30 14:00:47 grin $';
     print "$0 $VER (c) Peter 'grin' Gervai, 2021\n\n";
     print "Usage: $0 [--input input_file] [--pattern pattern_file] [--pattern another] [--top final_macro] \n";
-    print "          [--parsed parsed_outfile] [--failed failed_lines_file] [--debug n] [--noretrace] [--help]\n";
-    print "        input:   input file to be processed; default stdin\n";
-    print "        pattern: input grok-style pattern file; default patterns (name space pattern) (multiple possible)\n";
-    print "        top:     name of the pattern to match; default TEST\n";
-    print "        parsed:  output filename for parsed data; default stdout\n";
-    print "        failed:  output filename for lines not matched; default none\n";
-    print "        debug:   debug level 0 (none), 1 (error), 3 (warning), 7 (debug), 9 (trace)\n";
-    print "        notrace: disable regexp syntax check per pattern\n";
-    print "\n\n";
+    print "          [--parsed parsed_outfile] [--failed failed_lines_file] [--debug n] [--help]\n";
+    print "       defaults are stdin, stdout, 'patterns' as patternfile and 'TEST' as final macro.\n\n";
     exit;
 }
 
@@ -93,9 +85,9 @@
 &d(9, "RESULT\n========\n${top} = $res" );
 &d(9, "Pattern length=" . length($res) );
 
+## test final pattern
 eval {
-    my $test = "abc123";
-    $test =~ /$res/;
+    my $test = qr($res);
 };
 if( $@ ) {
     print "ERR: $@\n\n";
@@ -176,7 +168,7 @@
 
     if( $re_trace ) {
         # die if regexp is bad
-        "abc" =~ /$data/;
+        my $test = qr($data);
     }
 
     # release loop protection for $key