233 |
|
|
234 |
$self->{'tag'} = $type2tag{$type_base}; |
$self->{'tag'} = $type2tag{$type_base}; |
235 |
|
|
236 |
print STDERR "using type ",$self->{'type'}," tag ",$self->{'tag'},"\n" if ($self->{'debug'}); |
print STDERR "using type '",$self->{'type'},"' tag <",$self->{'tag'},">\n" if ($self->{'debug'}); |
237 |
|
|
238 |
my $f = "./import_xml/".$self->{'type'}.".xml"; |
my $f = "./import_xml/".$self->{'type'}.".xml"; |
239 |
confess "import_xml file '$f' doesn't exist!" if (! -e "$f"); |
confess "import_xml file '$f' doesn't exist!" if (! -e "$f"); |
349 |
|
|
350 |
=cut |
=cut |
351 |
|
|
352 |
|
# internal function to eval code |
353 |
|
sub _eval { |
354 |
|
my $self = shift; |
355 |
|
|
356 |
|
my $code = shift || return; |
357 |
|
no strict 'subs'; |
358 |
|
my $ret = eval $code; |
359 |
|
if ($@) { |
360 |
|
print STDERR "problem with eval code [$code]: $@\n"; |
361 |
|
} |
362 |
|
return $ret; |
363 |
|
} |
364 |
|
|
365 |
sub fill_in { |
sub fill_in { |
366 |
my $self = shift; |
my $self = shift; |
367 |
|
|
385 |
if ($found) { |
if ($found) { |
386 |
if ($eval_code) { |
if ($eval_code) { |
387 |
my $eval = $self->fill_in($rec,$eval_code,$i); |
my $eval = $self->fill_in($rec,$eval_code,$i); |
388 |
return if (! eval $eval); |
return if (! $self->_eval($eval)); |
389 |
} |
} |
390 |
# do we have lookups? |
# do we have lookups? |
391 |
if ($format =~ /\[[^\[\]]+\]/o) { |
if ($format =~ /\[[^\[\]]+\]/o) { |
392 |
|
print "## probable lookup: $format\n"; |
393 |
return $self->lookup($format); |
return $self->lookup($format); |
394 |
} else { |
} else { |
395 |
return $format; |
return $format; |
416 |
|
|
417 |
if ($tmp =~ /\[[^\[\]]+\]/o) { |
if ($tmp =~ /\[[^\[\]]+\]/o) { |
418 |
my @in = ( $tmp ); |
my @in = ( $tmp ); |
419 |
|
print "## lookup $tmp\n"; |
420 |
my @out; |
my @out; |
421 |
while (my $f = shift @in) { |
while (my $f = shift @in) { |
422 |
if ($f =~ /\[([^\[\]]+)\]/) { |
if ($f =~ /\[([^\[\]]+)\]/) { |
497 |
|
|
498 |
if ($eval_code) { |
if ($eval_code) { |
499 |
my $eval = $self->fill_in($rec,$eval_code,$i); |
my $eval = $self->fill_in($rec,$eval_code,$i); |
500 |
return if (! eval $eval); |
return if (! $self->_eval($eval)); |
501 |
} |
} |
502 |
|
|
503 |
return $out; |
return $out; |