+This function returns hash which is like this:
+
+ '200' => [
+ {
+ 'i1' => '1',
+ 'i2' => ' '
+ 'a' => 'Goa',
+ 'f' => 'Valdo D\'Arienzo',
+ 'e' => 'tipografie e tipografi nel XVI secolo',
+ }
+ ],
+
+This method will also create additional field C<000> with MFN.
+
+=cut
+
+sub to_hash {
+ my $self = shift;
+
+ my $mfn = shift || confess "need mfn!";
+
+ # init record to include MFN as field 000
+ my $rec = { '000' => [ $mfn ] };
+
+ my $row = $self->fetch($mfn) || return;
+
+ foreach my $rec_nr (keys %{$row}) {
+ foreach my $l (@{$row->{$rec_nr}}) {
+
+ # remove end marker
+ $l =~ s/\x1E$//;
+
+ # filter output
+ $l = $self->{'hash_filter'}->($l, $rec_nr) if ($self->{'hash_filter'});
+
+ my $val;
+
+ # has identifiers?
+ ($val->{'i1'},$val->{'i2'}) = ($1,$2) if ($l =~ s/^([01 #])([01 #])\x1F/\x1F/);
+
+ # has subfields?
+ if ($l =~ m/\x1F/) {
+ foreach my $t (split(/\x1F/,$l)) {
+ next if (! $t);
+ my $f = substr($t,0,1);
+ # repeatable subfileds. When we hit first one,
+ # store CURRENT (up to that) in first repetition
+ # of this record. Then, new record with same
+ # identifiers will be created.
+ if ($val->{$f}) {
+ push @{$rec->{$rec_nr}}, $val;
+ $val = {
+ i1 => $val->{i1},
+ i2 => $val->{i2},
+ };
+ }
+ $val->{substr($t,0,1)} = substr($t,1);
+ }
+ } else {
+ $val = $l;
+ }
+
+ push @{$rec->{$rec_nr}}, $val;
+ }
+ }
+
+ return $rec;
+}
+
+=head2 to_ascii
+
+ print $marc->to_ascii( 42 );
+
+=cut
+
+sub to_ascii {
+ my $self = shift;
+
+ my $mfn = shift || confess "need mfn";
+ my $row = $self->fetch($mfn) || return;
+
+ my $out;
+
+ foreach my $f (sort keys %{$row}) {
+ my $dump = join('', @{ $row->{$f} });
+ $dump =~ s/\x1e$//;
+ $dump =~ s/\x1f/\$/g;
+ $out .= "$f\t$dump\n";
+ }
+
+ return $out;
+}
+
+1;
+__END__