/usr/bin/index_dump is in libdbd-xbase-perl 1:1.05-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | #!/usr/bin/perl -w
eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
if 0; # not running under some shell
#!/usr/bin/perl -w
use strict;
use XBase::Index;
use Getopt::Long;
my %opts = ();
my $type;
my $startvalue;
my $showtotal;
GetOptions('debug:i' => sub { my $key = shift; my $val = shift;
$val = 1 if $val eq '0';
$XBase::Index::DEBUG = $val },
'type=s' => sub { my $key = shift;
my $val = shift;
if ($val eq 'num') { $type = 'N'; }
elsif ($val eq 'date') { $type = 'D'; }
elsif ($val eq 'char') { $type = 'C'; }
elsif ($val eq 'string') { $type = 'C'; }
else { die "Unknown index type `$val'\n"; }
},
'start=s' => \$startvalue,
'tag=s' => sub { $opts{'tag'} = $_[1]; },
'n' => sub { $showtotal = 1; },
);
$opts{'type'} = $type if defined $type;
# AUDIO 4608
# FACILITY 3072
# FILM 9216
# MAIN 7680
# ROOMNAME 1536
my $file = shift;
if (@ARGV and not defined $opts{'tag'}) { $opts{'tag'} = shift; }
my $index = new XBase::Index $file, %opts or die XBase::Index->errstr;
if (not defined $opts{'tag'}) {
my @tags = $index->tags;
if (@tags) {
print map "$_\n", @tags;
my $numtags = @tags;
print "Number of tags: $numtags\n" if $showtotal;
exit;
}
}
if (defined $startvalue) {
$index->prepare_select_eq($startvalue) or die $index->errstr;
}
else {
$index->prepare_select or die $index->errstr;
}
my $i = 0;
while (my @data = $index->fetch())
{
print "@data\n";
$i++;
}
if ($index->errstr) { die $index->errstr; }
print "Total records: $i\n" if $showtotal;
=head1 NAME
index_dump - Show the content of the index file
=head1 FORMAT
index_dump [options] file [ tag ]
where options are
--debug set debug level
--type specifies the num/date/char type of the index
--start defines the value to start dump from
--n prints also the total number of records
in the file
=head1 SYNOPSIS
index_dump rooms.cdx FACILITY
index_dump --debug=14 --start=Dub rooms.cdx ROOMNAME
=head1 DESCRIPTION
Index_dump prints to standard output the content of the index file.
The type of the index is one of those supported by the XBase::Index
Perl module (cdx, idx, ntx, ndx, mdx).
The output contains the index key and the value, which is the record
number in the correcponding dbf file.
For mulitag index files (like cdx), you need to specify the tag name
to get the actual data.
=head1 AVAILABLE FROM
http://www.adelton.com/perl/DBD-XBase/
=head1 AUTHOR
(c) 1999--2013 Jan Pazdziora.
=head1 SEE ALSO
perl(1); XBase::Index(3pm); dbf_dump(1p)
=cut
__END__
|