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