-
package MARC::Fast;
+
use strict;
use Carp;
use Data::Dumper;
BEGIN {
use Exporter ();
use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
- $VERSION = 0.04;
+ $VERSION = 0.05;
@ISA = qw (Exporter);
#Give a hoot don't pollute, do not export more than needed by default
@EXPORT = qw ();
return $rec;
}
+=head2 to_ascii
-1;
-__END__
+ print $marc->to_ascii( 42 );
+
+=cut
-=head1 BUGS
+sub to_ascii {
+ my $self = shift;
+ my $mfn = shift || confess "need mfn";
+ my $row = $self->fetch($mfn) || return;
+ my $out;
-=head1 SUPPORT
+ 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__
=head1 AUTHOR
=head1 SEE ALSO
-perl(1).
+L<Biblio::Isis>, perl(1).
=cut
my $rec = $marc->fetch($mfn) || next;
print "rec is ",Dumper($rec) if ($opt{d});
print "REC $mfn\n";
- foreach my $f (sort keys %{$rec}) {
- my $dump = join('', @{ $rec->{$f} });
- $dump =~ s/\x1e$//;
- $dump =~ s/\x1f/\$/g;
- print "$f\t$dump\n";
- }
- print "\n";
+ print $marc->to_ascii($mfn),"\n";
print "hash is ",Dumper($marc->to_hash($mfn)) if ($opt{h});
}
use strict;
use blib;
-use Test::More tests => 20;
+use Test::More tests => 40;
use Test::Exception;
-use Data::Dumper;
+use Data::Dump qw/dump/;
BEGIN { use_ok( 'MARC::Fast' ); }
+my $debug = shift @ARGV;
+
my $marc;
my %param;
ok($marc->fetch($_), "fetch $_");
ok(my $hash = $marc->to_hash($_), "to_hash $_");
- diag "$_ :: ",Dumper($hash);
+ diag "to_hash($_) = ",dump($hash) if ($debug);
+ ok(my $ascii = $marc->to_ascii($_), "to_ascii $_");
+ diag "to_ascii($_) ::\n$ascii" if ($debug);
}
}