--- trunk2/lib/WebPAC.pm 2004/06/16 13:39:17 357 +++ trunk2/lib/WebPAC.pm 2004/06/16 14:31:33 358 @@ -4,6 +4,8 @@ use Text::Iconv; use Config::IniFiles; +use Data::Dumper; + =head1 NAME WebPAC - base class for WebPAC @@ -340,31 +342,46 @@ my ($rec, $format, $i) = @_; + confess("need HASH as first argument!") if ($rec !~ /HASH/o); + + $i = 0 if (! $i); + my @out; my $eval_code; # remove eval{...} from beginning $eval_code = $1 if ($format =~ s/^eval{([^}]+)}//s); - my $prefix = ''; - $prefix = $1 if ($format =~ s/^(.+)(v\d+(?:\^\w)*)/$2/s); + my $prefix; + my $all_found=0; - sub f_sf_del { - my ($self,$rec,$out,$f,$sf,$del,$i) = @_; +print "## $format\n"; + while ($format =~ s/^(.*?)v(\d+)(?:\^(\w))*//s) { +print "## [ $1 | $2 | $3 ] $format\n"; + + my $del = $1 || ''; + $prefix ||= $del; + + my $found = 0; + my $tmp = $self->get_data(\$rec,$2,$3,$i,\$found); - my $found=0; - my $tmp = $self->get_data($rec,$f,$sf,$i,\$found); if ($found) { - push @{$$out}, $tmp; - push @{$$out}, $del; + push @out, $del; + push @out, $tmp; + $all_found += $found; } - return ''; } - #$format =~ s/(.*)v(\d+)(?:\^(\w))*/f_sf_del($self,\$rec,\@out,$2,$3,$1,$i/ges; + return if (! $all_found); + + print Dumper($prefix, \@out); - print Dumper(@out); + my $out = join('',@out) . $format; + # add prefix if not there + $out = $prefix . $out if ($out !~ m/^\Q$prefix\E/); + + return $out; } 1;