+ foreach my $from (keys %{ $modify_record->{$f}->{$sf} }) {
+ my $to = $modify_record->{$f}->{$sf}->{$from};
+ #die "no field?" unless defined($to);
+ my $d = "|$from| -> |$to|";
+ $log->debug("transform: $d");
+
+ my $regex = _get_regex($sf,$from,$to);
+ push @{ $regexpes->{$f} }, { regex => $regex, debug => $d };
+ $log->debug("regex: $regex");
+ }
+ }
+ }
+
+ return $regexpes;
+}
+
+=head2 modify_file_regexps
+
+Generate hash with regexpes to be applied using L<filter> from
+pseudo hash/yaml format for regex mappings.
+
+It should be obvious:
+
+ 200
+ '^a'
+ ' : ' => '^e'
+ ' = ' => '^d'
+
+In field I<200> find C<'^a'> and then C<' : '>, and replace it with C<'^e'>.
+In field I<200> find C<'^a'> and then C<' = '>, and replace it with C<'^d'>.
+
+ my $regexpes = $input->modify_file_regexps( 'conf/modify/common.pl' );
+
+On undef path it will just return.
+
+=cut
+
+sub modify_file_regexps {
+ my $self = shift;
+
+ my $modify_path = shift || return;
+
+ my $log = $self->_get_logger();
+
+ my $regexpes;
+
+ CORE::open(my $fh, '<:encoding(utf-8)', $modify_path) || $log->logdie("can't open modify file $modify_path: $!");
+
+ my ($f,$sf);
+
+ while(<$fh>) {
+ chomp;
+ next if (/^#/ || /^\s*$/);
+
+ if (/^\s*(\d+)\s*$/) {
+ $f = $1;
+ $log->debug("field: $f");
+ next;
+ } elsif (/^\s*'([^']*)'\s*$/) {
+ $sf = $1;
+ $log->die("can't define subfiled before field in: $_") unless ($f);
+ $log->debug("subfield: $sf");
+ } elsif (/^\s*'([^']*)'\s*=>\s*'([^']*)'\s*$/) {
+ my ($from,$to) = ($1, $2);
+
+ $log->debug("transform: |$from| -> |$to|");
+
+ my $regex = _get_regex($sf,$from,$to);
+ push @{ $regexpes->{$f} }, {
+ regex => $regex,
+ file => $modify_path,
+ line => $.,
+ };
+ $log->debug("regex: $regex");
+ } else {
+ die "can't parse: $_";
+ }
+ }
+
+ return $regexpes;
+}