--- trunk2/lib/WebPAC.pm 2004/06/17 17:25:12 370 +++ trunk2/lib/WebPAC.pm 2004/06/17 20:44:45 371 @@ -233,7 +233,7 @@ $self->{'tag'} = $type2tag{$type_base}; - 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'}); my $f = "./import_xml/".$self->{'type'}.".xml"; confess "import_xml file '$f' doesn't exist!" if (! -e "$f"); @@ -349,6 +349,19 @@ =cut +# internal function to eval code +sub _eval { + my $self = shift; + + my $code = shift || return; + no strict 'subs'; + my $ret = eval $code; + if ($@) { + print STDERR "problem with eval code [$code]: $@\n"; + } + return $ret; +} + sub fill_in { my $self = shift; @@ -372,10 +385,11 @@ if ($found) { if ($eval_code) { my $eval = $self->fill_in($rec,$eval_code,$i); - return if (! eval $eval); + return if (! $self->_eval($eval)); } # do we have lookups? if ($format =~ /\[[^\[\]]+\]/o) { +print "## probable lookup: $format\n"; return $self->lookup($format); } else { return $format; @@ -402,6 +416,7 @@ if ($tmp =~ /\[[^\[\]]+\]/o) { my @in = ( $tmp ); +print "## lookup $tmp\n"; my @out; while (my $f = shift @in) { if ($f =~ /\[([^\[\]]+)\]/) { @@ -482,7 +497,7 @@ if ($eval_code) { my $eval = $self->fill_in($rec,$eval_code,$i); - return if (! eval $eval); + return if (! $self->_eval($eval)); } return $out;