[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

ASCII Dump



It took me a while, but here's the programs to dump the ZigZag
database to ASCII and back.


To save zigzag.data:
   ./zzdump > file_to_save_to

To restore:
   ./zzundump < file_to_restore_from



Gossamer

-- 
: Gossamer - gossamer@xxxxxxxxxxxxxx - http://www.tertius.net.au/~gossamer/
:         ***   Link of the week:  http://www.gnuhoo.com/    ***
: You don't have to wait to be asked.  -- Larry Niven
#!/usr/bin/perl -w
#
# Database Dump-To-ASCII for ZigZag
#
# Programmed by Bek Oberin ("Gossamer")
# Copyright (c) 1997, 1998 Project Xanadu
#
# For more information, visit http://www.xanadu.net/zz/
#
# ===================== Change Log
#
# $Id: zzdump,v 1.1 1998/06/20 13:25:24 gossamer Exp gossamer $
#
# $Log: zzdump,v $
# Revision 1.1  1998/06/20 13:25:24  gossamer
# Initial revision
#

use strict;
use DB_File;
use Fcntl;

use Data::Dumper;

# Note: We are using the following naming convention:
# Constants are named in ALLCAPS
# Global variables are named with Initial Caps
# Local variables and functions are named in lowercase
# Function calls to functions defined in this file all start with & except
#    the Curses ones.
# Put brackets around all function arguments.

# Define constants
my $FILENAME = "zigzag.data";    # Default filename for initial slice

#
# Main
#

my %ZZ;

$Data::Dumper::Indent = 2;  # NB  Make this an option, set to 0 if -t?
$Data::Dumper::Purity = 1;

my $Filename = shift || $FILENAME;
tie(%ZZ, 'DB_File', $Filename, O_RDONLY) ||
   die "Can't open \"$Filename\": $!\n";

my $d = Data::Dumper->new([\%ZZ], [qw(*ZZ)]);
$d->Purity(1)->Terse(1)->Deepcopy(1);
print $d->Dump;

#print Data::Dumper->Dump([\%ZZ], [qw(*ZZdump)]);
#print Data::Dumper->Dump([\%ZZ]);

#
# End.
#
#!/usr/bin/perl -w
#
# ASCII Dump to Database for ZigZag
#
# Programmed by Bek Oberin ("Gossamer")
# Copyright (c) 1997, 1998 Project Xanadu
#
# For more information, visit http://www.xanadu.net/zz/
#
# ===================== Change Log
#
# $Id: zzundump,v 1.1 1998/06/20 13:25:24 gossamer Exp gossamer $
#
# $Log: zzundump,v $
# Revision 1.1  1998/06/20 13:25:24  gossamer
# Initial revision
#

use strict;
use DB_File;
use Fcntl;

use Data::Dumper;

# Define constants
my $FILENAME = "zigzag.data";    # Default filename for initial slice

#
# Main
#

my %ZZ;

# open the DB file
my $Filename = shift || $FILENAME;
if (-e $Filename) {
   # XXX unless -f force
   warn "Error: database \"$Filename\" already exists.";
   exit;
}
tie %ZZ, 'DB_File', $Filename, O_CREAT | O_RDWR || 
   die "Can't open \"$Filename\": $!\n";

undef $/;
%ZZ = eval <>;

#
# End.
#