document all options, fix offset and limit
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 13 Oct 2013 22:08:55 +0000 (00:08 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 13 Oct 2013 22:12:41 +0000 (00:12 +0200)
META.yml [deleted file]
scripts/dump_fastmarc.pl

diff --git a/META.yml b/META.yml
deleted file mode 100644 (file)
index 1e9c3a0..0000000
--- a/META.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-# http://module-build.sourceforge.net/META-spec.html
-#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
-name:         MARC-Fast
-version:      0.03
-version_from: Fast.pm
-installdirs:  site
-requires:
-    Carp:                          0
-    Test::Exception:               0
-    Test::Simple:                  0.44
-
-distribution_type: module
-generated_by: ExtUtils::MakeMaker version 6.17
index dd4897c..a940007 100755 (executable)
@@ -27,6 +27,10 @@ dump records starting with C<offset>
 
 dump just C<limit> records
 
+=item -n mfn
+
+dump single C<mfn> record (same as C<-o mfn -l 1>)
+
 =item -h
 
 dump result of C<to_hash> on record
@@ -44,17 +48,16 @@ dump tsv file for TokyoCabinet import
 =cut
 
 my %opt;
-getopts('do:l:ht', \%opt);
+getopts('do:l:n:ht', \%opt);
 
-my $file = shift @ARGV || die "usage: $0 [-o offset] [-l limit] [-h] [-d] file.marc\n";
+my $file = shift @ARGV || die "usage: $0 [-o offset] [-l limit] [-n single_mfn] [-h] [-d] [-t] file.marc\n";
 
 my $marc = new MARC::Fast(
        marcdb => $file,
        debug => $opt{d},
 );
 
-
-my $min = 1;
+my $min = $opt{o} || 1;
 my $max = $marc->count;
 
 if (my $mfn = $opt{n}) {
@@ -62,7 +65,7 @@ if (my $mfn = $opt{n}) {
        print STDERR "Dumping $mfn only\n";
 } elsif (my $limit = $opt{l}) {
        print STDERR "$file has $max records, using first $limit\n";
-       $max = $limit;
+       $max = $min + $limit - 1;
 } else {
        print STDERR "$file has $max records...\n";
 }