r857@llin: dpavlin | 2006-08-23 13:04:58 +0200
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 23 Aug 2006 11:04:32 +0000 (11:04 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 23 Aug 2006 11:04:32 +0000 (11:04 +0000)
 modify_records is now applied only once for each field to prevent looping of regexpes

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@613 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Input.pm
run.pl

index f748594..4e58da2 100644 (file)
@@ -16,11 +16,11 @@ WebPAC::Input - read different file formats into WebPAC
 
 =head1 VERSION
 
-Version 0.09
+Version 0.10
 
 =cut
 
-our $VERSION = '0.09';
+our $VERSION = '0.10';
 
 =head1 SYNOPSIS
 
@@ -258,14 +258,21 @@ sub open {
 
                                return $l unless ($rec_regex && $f_nr);
 
+#                              my $max_regex = 100;
+
                                # apply regexps
                                if ($rec_regex && defined($rec_regex->{$f_nr})) {
                                        $log->logconfess("regexps->{$f_nr} must be ARRAY") if (ref($rec_regex->{$f_nr}) ne 'ARRAY');
                                        my $c = 0;
                                        foreach my $r (@{ $rec_regex->{$f_nr} }) {
-                                               while ( eval '$l =~ ' . $r ) { $c++ };
+                                               #$log->debug("\$l = $l\neval \$l =~ $r");
+                                               eval '$l =~ ' . $r;
+                                               $log->error("error applying regex: $r") if ($@);
+
+#                                              while ( $c < $max_regex && eval '$l =~ ' . $r ) { $c++ };
+#                                              $log->error("field $f_nr has more than $max_regex regex iterations\n\$l = $l\neval \$l =~ $r") if ($c == $max_regex);
+
                                        }
-                                       warn "## field $f_nr triggered $c regexpes\n" if ($c && $self->{debug});
                                }
 
                                return $l;
diff --git a/run.pl b/run.pl
index 62d3589..318daac 100755 (executable)
--- a/run.pl
+++ b/run.pl
@@ -8,7 +8,7 @@ use lib './lib';
 
 use WebPAC::Common 0.02;
 use WebPAC::Lookup 0.03;
-use WebPAC::Input 0.07;
+use WebPAC::Input 0.10;
 use WebPAC::Store 0.03;
 use WebPAC::Normalize 0.11;
 use WebPAC::Output::TT;