#!/usr/local/bin/perl -I ../lib

use Data::MagicTie;
use Data::Dumper;

$Data::Dumper::Indent = 1;

die "Usage: $0 <filename>  <see_values> [<style> <split_factor> <host> <port>]\n"
	unless($#ARGV>=1);

my $file = shift;
$file =~ s/\.([dbm]+)$//;
my $seevalues = shift;
my $style = shift;
my $Q = shift;
undef $Q
	unless ($Q =~ /\d+/);
my $host = shift;
undef $host
	unless($host ne '');
my $port = shift;
undef $port
	unless($port =~ /\d+/);

tie %tmp, "Data::MagicTie",
		( Name => $file, Mode => 'r', Split => $Q, Style => $style, Host => $host, Port => $port )
	or die "Could not open $file: $!";

while(($k,$v)=each %tmp) {
	#$k =~ s/[\x00-\x1f]/sprintf("%%%2x",\1)/eg;
	#$v =~ s/[\x00-\x1f]/sprintf("%%%2x",\1)/eg;

	$v= Dumper( $v ) if ref($v);

	print "'$k'";
	print "=\t$v"
		if $seevalues;
	print "\n";
	};
untie %tmp;
