/[webpac]/branches/tehnika/to_hash.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /branches/tehnika/to_hash.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 684 - (show annotations)
Mon Feb 28 10:43:38 2005 UTC (15 years, 9 months ago) by dpavlin
File size: 824 byte(s)
updated branches to head

1 # 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;

  ViewVC Help
Powered by ViewVC 1.1.26