268 |
|
|
269 |
my $found = 0; |
my $found = 0; |
270 |
|
|
271 |
|
my $eval_code; |
272 |
|
# remove eval{...} from beginning |
273 |
|
$eval_code = $1 if ($format =~ s/^eval{([^}]+)}//s); |
274 |
|
|
275 |
# do actual replacement of placeholders |
# do actual replacement of placeholders |
276 |
$format =~ s/v(\d+)(?:\^(\w))*/$self->get_data(\$rec,$1,$2,$i,\$found)/ges; |
$format =~ s/v(\d+)(?:\^(\w))*/$self->get_data(\$rec,$1,$2,$i,\$found)/ges; |
277 |
|
|
278 |
if ($found) { |
if ($found) { |
279 |
|
if ($eval_code) { |
280 |
|
my $eval = $self->fill_in($rec,$eval_code,$i); |
281 |
|
return if (! eval $eval); |
282 |
|
} |
283 |
# do we have lookups? |
# do we have lookups? |
284 |
if ($format =~ /\[[^\[\]]+\]/o) { |
if ($format =~ /\[[^\[\]]+\]/o) { |
285 |
return $self->lookup($format); |
return $self->lookup($format); |
363 |
my $prefix; |
my $prefix; |
364 |
my $all_found=0; |
my $all_found=0; |
365 |
|
|
366 |
print "## $format\n"; |
#print "## $format\n"; |
367 |
while ($format =~ s/^(.*?)v(\d+)(?:\^(\w))*//s) { |
while ($format =~ s/^(.*?)v(\d+)(?:\^(\w))*//s) { |
368 |
print "## [ $1 | $2 | $3 ] $format\n"; |
#print "## [ $1 | $2 | $3 ] $format\n"; |
369 |
|
|
370 |
my $del = $1 || ''; |
my $del = $1 || ''; |
371 |
$prefix ||= $del; |
$prefix ||= $del if ($all_found == 0); |
372 |
|
|
373 |
my $found = 0; |
my $found = 0; |
374 |
my $tmp = $self->get_data(\$rec,$2,$3,$i,\$found); |
my $tmp = $self->get_data(\$rec,$2,$3,$i,\$found); |
382 |
|
|
383 |
return if (! $all_found); |
return if (! $all_found); |
384 |
|
|
|
print Dumper($prefix, \@out); |
|
|
|
|
385 |
my $out = join('',@out) . $format; |
my $out = join('',@out) . $format; |
386 |
|
|
387 |
# add prefix if not there |
# add prefix if not there |
388 |
$out = $prefix . $out if ($out !~ m/^\Q$prefix\E/); |
$out = $prefix . $out if ($out !~ m/^\Q$prefix\E/); |
389 |
|
|
390 |
|
if ($eval_code) { |
391 |
|
my $eval = $self->fill_in($rec,$eval_code,$i); |
392 |
|
return if (! eval $eval); |
393 |
|
} |
394 |
|
|
395 |
return $out; |
return $out; |
396 |
} |
} |
397 |
|
|