Revision 755 (by dpavlin, 2006/10/29 16:42:48) new branch for electronic journals
# This is slight modification of to_hash as included in Biblio::Isis
#
# This is incredibly bad (duplicate code), but it would have to wait for
# WebPac v2 to be fixed by extracting all file imported in sane OO way.


sub to_hash {
	my $mfn = shift || confess "need mfn!";
	my $row = shift || confess "need data";

	# init record to include MFN as field 000
	my $rec = { '000' => [ $mfn ] };

	foreach my $k (keys %{$row}) {
		foreach my $l (@{$row->{$k}}) {

			my $val;

			# has identifiers?
			#($val->{'i1'},$val->{'i2'}) = ($1,$2) if ($l =~ s/^([01 #])([01 #])\^/\^/);

			# has subfields?
			if ($l =~ m/[\^\$]/) {
				foreach my $t (split(/[\^\$]/,$l)) {
					next if (! $t);
					$val->{substr($t,0,1)} = substr($t,1);
				}
			} else {
				$val = $l;
			}

			push @{$rec->{$k}}, $val;
		}
	}

	return $rec;
}

1;