1 |
#------------------------------------------------------------- |
2 |
# |
3 |
# parse_format('format',$isis_row); |
4 |
# |
5 |
|
6 |
use isis_sf; |
7 |
|
8 |
sub parse_format { |
9 |
my $format = shift; |
10 |
my $row = shift; |
11 |
|
12 |
my $out; |
13 |
my $out_swish; |
14 |
|
15 |
my $prefix = ""; |
16 |
if ($format =~ s/^([^\d]+)//) { |
17 |
$prefix = "pre: $1"; |
18 |
} |
19 |
|
20 |
my $display; |
21 |
my $swish; |
22 |
|
23 |
while ($format) { |
24 |
#print STDERR "#### $format\n"; |
25 |
if ($format =~ s/^(\d\d\d)(\w?)//) { |
26 |
my $isis_tmp = isis_sf($row,$1,$2); |
27 |
if ($isis_tmp) { |
28 |
$display .= $prefix . $isis_tmp; |
29 |
$swish .= $isis_tmp." "; |
30 |
} |
31 |
$prefix = ""; |
32 |
# this might be our local scpeciality -- fields 10 and 11 |
33 |
# (as opposed to 010 and 011) so they are strictly listed |
34 |
# here |
35 |
} elsif ($format =~ s/^(1[01])//) { |
36 |
my $isis_tmp = isis_sf($row,$1,$2); |
37 |
if ($isis_tmp) { |
38 |
$display .= $prefix . $isis_tmp; |
39 |
$swish .= $isis_tmp." "; |
40 |
} |
41 |
$prefix = ""; |
42 |
} elsif ($format =~ s/^([^\d]+)(\d{0,3})/$2/) { |
43 |
$prefix .= $1; |
44 |
} elsif ($format =~ s/^([^\d]+\d{0,2})//) { |
45 |
$prefix .= $1; |
46 |
} elsif ($format =~ s/^(\d{1,2})//) { |
47 |
$prefix .= $1; |
48 |
} else { |
49 |
print STDERR "unparsed format: $format\n"; |
50 |
$prefix .= $format; |
51 |
$format = ""; |
52 |
} |
53 |
} |
54 |
# add suffix |
55 |
$display .= $prefix if ($display); |
56 |
|
57 |
return ($swish,$display); |
58 |
} |
59 |
|
60 |
#------------------------------------------------------------- |
61 |
1; |