sub _get_regex {
my ($sf,$from,$to) = @_;
+ if ($from =~ m/^regex:(.+)$/) {
+ $from = $1;
+ } else {
+ $from = '\Q' . $from . '\E';
+ }
if ($sf =~ /^\^/) {
return
- 's/\Q'. $sf .'\E([^\^]*?)\Q'. $from .'\E([^\^]*?)/'. $sf .'$1'. $to .'$2/';
+ 's/\Q'. $sf .'\E([^\^]*?)'. $from .'([^\^]*?)/'. $sf .'$1'. $to .'$2/';
} else {
return
- 's/\Q'. $from .'\E/'. $to .'/g';
+ 's/'. $from .'/'. $to .'/g';
}
}
ok($input->open( path => "$abs_path/modify_isis/LIBRI", ), "open modify_isis (plain)");
ok(my $rec_p = $input->fetch, 'fetch');
+# modify_records
+
ok($input->open(
path => "$abs_path/modify_isis/LIBRI",
modify_records => {
cmp_ok($rec_p->{200}->[0]->{f} . '. ' . $rec_p->{200}->[0]->{c}, 'eq' ,$rec->{200}->[0]->{f}, 'modify_records working');
+diag dump($input);
+
+# break encapsulation, bad! bad!
+$input->{ll_db}->{record} = {
+ 900 => 'foo ; bar ; baz',
+};
+
+$input->{modify_record} = {
+ 900 => {
+ '*' => {
+ ' ; ' => 'a',
+ }
+ }
+};
+
+diag "hacked: ",dump($input, $input->fetch);