#!/usr/bin/perl -w
######################################################################
# (c) Michael Schilli 1999
######################################################################

use Tk;
use POSIX;
use SDBM_File;

usage() if $#ARGV < 0;
                              # Persistenten Hash öffnen
tie(%myhash, SDBM_File, $ARGV[0], O_RDONLY, 0644) || 
     do { print "Cannot open $ARGV[0]\n"; usage() };

my $top = MainWindow->new();

                            # Listbox erzeugen
$listbox = $top->ScrlListbox(-label => "Hash: $ARGV[0]");

                            # Buttons
$exitbutton   = $top->Button(-text => "Exit", 
                             -command => \&exit);

                            # Alles Packen
$listbox->pack(-fill   => "both", "-expand" => "yes");
$exitbutton->pack(-side => "left");

                            # Listbox füllen
foreach $i (keys %myhash) {
    $listbox->insert("end", "$i> $myhash{$i}");
}

MainLoop;

###############################################################
# usage
###############################################################
sub usage {
    ($func = $0) =~ s,^.*/,,g;
    print "usage: $func dbmfilename\n";
    exit 1;
}
