551 |
|
|
552 |
my $regexpes; |
my $regexpes; |
553 |
|
|
554 |
|
my $log = $self->_get_logger(); |
555 |
|
|
556 |
foreach my $f (keys %$modify_record) { |
foreach my $f (keys %$modify_record) { |
557 |
warn "--- f: $f\n"; |
$log->debug("field: $f"); |
558 |
|
|
559 |
foreach my $sf (keys %{ $modify_record->{$f} }) { |
foreach my $sf (keys %{ $modify_record->{$f} }) { |
560 |
warn "---- sf: $sf\n"; |
$log->debug("subfield: $sf"); |
561 |
|
|
562 |
foreach my $from (keys %{ $modify_record->{$f}->{$sf} }) { |
foreach my $from (keys %{ $modify_record->{$f}->{$sf} }) { |
563 |
my $to = $modify_record->{$f}->{$sf}->{$from}; |
my $to = $modify_record->{$f}->{$sf}->{$from}; |
564 |
#die "no field?" unless defined($to); |
#die "no field?" unless defined($to); |
565 |
warn "----- transform: |$from| -> |$to|\n"; |
$log->debug("transform: |$from| -> |$to|"); |
566 |
|
|
567 |
if ($sf =~ /^\^/) { |
if ($sf =~ /^\^/) { |
568 |
my $regex = |
my $regex = |
569 |
's/\Q'. $sf .'\E([^\^]+)\Q'. $from .'\E([^\^]+)/'. $sf .'$1'. $to .'$2/g'; |
's/\Q'. $sf .'\E(.*?)\Q'. $from .'\E(.*?)/'. $sf .'$1'. $to .'$2/g'; |
570 |
push @{ $regexpes->{$f} }, $regex; |
push @{ $regexpes->{$f} }, $regex; |
571 |
warn ">>>>> $regex [sf]\n"; |
$log->debug(">>>>> $regex [sf]"); |
572 |
} else { |
} else { |
573 |
my $regex = |
my $regex = |
574 |
's/\Q'. $from .'\E/'. $to .'/g'; |
's/\Q'. $from .'\E/'. $to .'/g'; |
575 |
push @{ $regexpes->{$f} }, $regex; |
push @{ $regexpes->{$f} }, $regex; |
576 |
warn ">>>>> $regex [global]\n"; |
$log->debug(">>>>> $regex [global]"); |
577 |
} |
} |
578 |
|
|
579 |
} |
} |