1 |
dpavlin |
678 |
# This is slight modification of to_hash as included in Biblio::Isis |
2 |
|
|
# |
3 |
|
|
# This is incredibly bad (duplicate code), but it would have to wait for |
4 |
|
|
# WebPac v2 to be fixed by extracting all file imported in sane OO way. |
5 |
|
|
|
6 |
|
|
|
7 |
|
|
sub to_hash { |
8 |
|
|
my $mfn = shift || confess "need mfn!"; |
9 |
|
|
my $row = shift || confess "need data"; |
10 |
|
|
|
11 |
|
|
# init record to include MFN as field 000 |
12 |
|
|
my $rec = { '000' => [ $mfn ] }; |
13 |
|
|
|
14 |
|
|
foreach my $k (keys %{$row}) { |
15 |
|
|
foreach my $l (@{$row->{$k}}) { |
16 |
|
|
|
17 |
|
|
my $val; |
18 |
|
|
|
19 |
|
|
# has identifiers? |
20 |
|
|
#($val->{'i1'},$val->{'i2'}) = ($1,$2) if ($l =~ s/^([01 #])([01 #])\^/\^/); |
21 |
|
|
|
22 |
|
|
# has subfields? |
23 |
|
|
if ($l =~ m/[\^\$]/) { |
24 |
|
|
foreach my $t (split(/[\^\$]/,$l)) { |
25 |
|
|
next if (! $t); |
26 |
|
|
$val->{substr($t,0,1)} = substr($t,1); |
27 |
|
|
} |
28 |
|
|
} else { |
29 |
|
|
$val = $l; |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
push @{$rec->{$k}}, $val; |
33 |
|
|
} |
34 |
|
|
} |
35 |
|
|
|
36 |
|
|
return $rec; |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
1; |