/[Biblio-Isis]/trunk/t/2_isis.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/t/2_isis.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 62 by dpavlin, Mon Jul 10 12:01:04 2006 UTC revision 63 by dpavlin, Thu Jul 13 09:13:25 2006 UTC
# Line 281  $isis->{record} = { Line 281  $isis->{record} = {
281                  '^b901b-2 x 901b-2',                  '^b901b-2 x 901b-2',
282                  '^c901c-3 y 901c-3',                  '^c901c-3 y 901c-3',
283          ],          ],
284            902 => [
285                    '^a902a-1^b9002a-2',
286            ],
287  };  };
288    
289  my $split_on_delimiters = {  my $split_on_delimiters = {
290          900 => { a => { ' : ' => 'b', ' ; ' => 'c' } },          900 => { '^a' => { ' : ' => '^b', ' ; ' => '^c' } },
291          901 => {          901 => {
292                  a => { ' x ' => 'b', ' y ' => 'c' },                  '^a' => { ' x ' => '^b', ' y ' => '^c' },
293                  b => { ' x ' => 'b' },                  '^b' => { ' x ' => '^b' },
294                  c => { ' y ' => 'c' }                  '^c' => { ' y ' => '^c' }
295          },          },
296            902 => { '*' => { '^b' => ' * ' } },
297  };  };
298    
299  diag "split_on_delimiters = ", Dumper($split_on_delimiters);  diag "split_on_delimiters = ", Dumper($split_on_delimiters);
# Line 300  foreach my $f (keys %$split_on_delimiter Line 304  foreach my $f (keys %$split_on_delimiter
304  warn "--- f: $f\n";  warn "--- f: $f\n";
305          foreach my $sf (keys %{ $split_on_delimiters->{$f} }) {          foreach my $sf (keys %{ $split_on_delimiters->{$f} }) {
306  warn "---- sf: $sf\n";  warn "---- sf: $sf\n";
307                  foreach my $patt (keys %{ $split_on_delimiters->{$f}->{$sf} }) {                  foreach my $from (keys %{ $split_on_delimiters->{$f}->{$sf} }) {
308                          my $new_sf = $split_on_delimiters->{$f}->{$sf}->{$patt} || die "no field?";                          my $to = $split_on_delimiters->{$f}->{$sf}->{$from};
309  warn "----- patt: $patt -> $new_sf\n";                          #die "no field?" unless defined($to);
310    warn "----- transform: |$from| -> |$to|\n";
311                          # fool-proof spaces in pattern  
312                          $patt =~ s/\s+/\\s\+/g;                          if ($sf =~ /^\^/) {
313                                            my $regex =
314                          push @{ $regexpes->{$f} },                                          's/\Q'. $sf .'\E([^\^]+)\Q'. $from .'\E([^\^]+)/'. $sf .'$1'. $to .'$2/g';
315                  's/\^' . $sf . '([^\^]+)' . $patt . '([^\^]+)/^' . $sf . '$1^' . $new_sf . '$2/g';                                  push @{ $regexpes->{$f} }, $regex;
316    warn ">>>>> $regex [sf]\n";
317                            } else {
318                                    my $regex =
319                                            's/\Q'. $from .'\E/'. $to .'/g';
320                                    push @{ $regexpes->{$f} }, $regex;
321    warn ">>>>> $regex [global]\n";
322                            }
323    
324                  }                  }
325          }          }
326  }  }
# Line 325  is_deeply( $hash, { Line 337  is_deeply( $hash, {
337                { b => ["901b-2", "901b-2"] },                { b => ["901b-2", "901b-2"] },
338                { c => ["901c-3", "901c-3"] },                { c => ["901c-3", "901c-3"] },
339              ],              ],
340       902   => [{ a => "902a-1 * 9002a-2" }],
341  }, 'hash is_deeply');  }, 'hash is_deeply');
342    
343  ok($isis->{regexpes} = $regexpes, 'isis->{regexpes}');  ok($isis->{regexpes} = $regexpes, 'isis->{regexpes}');

Legend:
Removed from v.62  
changed lines
  Added in v.63

  ViewVC Help
Powered by ViewVC 1.1.26