2 # dump_stub_from_index.pl Outputs stubs from a tied index
3 # and is released under the terms of the GNU GPL version 3, or any
4 # later version, at your option. See the file README and COPYING for
6 # Copyright 2014 by Don Armstrong <don@donarmstrong.com>.
17 dump_stub_from_index.pl - Outputs stubs from a tied index
21 dump_stub_from_index.pl index.idx key1 [key2...]
24 --debug, -d debugging level (Default 0)
25 --help, -h display this help
26 --man, -m display manual
34 Debug verbosity. (Default 0)
38 Display brief usage information.
48 dump_stub_from_index.pl
54 use MLDBM qw(DB_File Storable);
59 $MLDBM::DumpMeth=q(portable);
61 my %options = (debug => 0,
67 'debug|d+','help|h|?','man|m');
69 pod2usage() if $options{help};
70 pod2usage({verbose=>2}) if $options{man};
72 $DEBUG = $options{debug};
76 push @USAGE_ERRORS,"You must give an index and at least one stub";
79 pod2usage(join("\n",@USAGE_ERRORS)) if @USAGE_ERRORS;
81 my ($index,@stubs) = @ARGV;
83 print "# dump_stub_from_index.pl ".basename($index)." ".join(' ',@stubs)."\n";
85 tie %db, "MLDBM",$index, O_RDONLY
86 or die "Unable to open and tie $index for reading: $!";
89 for my $stub (@stubs) {
90 $object{$stub} = $db{$stub};
92 print Data::Dumper->Dump([\%object],[qw($stub)]);