3
# Copyright © 1999 Roman Hodek <Roman.Hodek@informatik.uni-erlangen.de>
4
# Copyright © 2008 Roger Leigh <rleigh@debian.org
6
# This program is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 2 of the License, or
9
# (at your option) any later version.
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see
18
# <http://www.gnu.org/licenses/>.
20
#######################################################################
25
my $progname = basename($0);
30
use MLDBM qw(GDBM_File Storable);
32
die "Filename missing\n" if !@ARGV;
33
die "$ARGV[0]: $!\n" if !-f $ARGV[0];
35
if ($progname =~ /catdb/) {
36
tie %db, 'DB_File', $ARGV[0], O_RDONLY, 0664, $DB_HASH;
38
elsif ($progname =~ /catgdbm/) {
39
tie %db, 'GDBM_File', $ARGV[0], GDBM_READER, 0644;
41
elsif ($progname =~ /catmldbm/) {
42
tie %db, 'MLDBM', $ARGV[0], GDBM_READER, 0644;
45
die "Called for unknown db type\n";
51
my @keys = sort(keys(%db));
52
@keys = @ARGV if (@ARGV > 0);
54
foreach $key (@keys) {
56
if (exists $db{$key}) {
58
if (ref($val) eq "HASH") {
60
foreach (keys(%{$val})) {
61
print " $_: $val->{$_}\n";
64
print "$key:\n$db{$key}\n";
68
print "*UNDEFINED*\n";