#!/usr/bin/perl ############################################################ # dump_ndbm -- dump and undump ndbm data files # Mike Schilli , 2002 ############################################################ our $VERSION = "1.00"; our $CVSVERSION = '$Revision: 1.3 $'; use strict; use warnings; use Fcntl; use NDBM_File; use Data::Dumper; use Getopt::Std; use Pod::Usage; getopts("hvu:", \my %opts); pod2usage() if $opts{h}; my %hash; if($opts{u}) { # Undump requested tie %hash, "NDBM_File", $opts{u}, O_RDWR, 0644 or die "Cannot tie $opts{u}"; my $VAR1; my $in = join '', <>; eval $in; %hash = %$VAR1; } else { # Dump requested pod2usage() unless @ARGV; tie %hash, "NDBM_File", $ARGV[0], O_RDONLY, 0644 or die "Cannot tie $ARGV[0]"; print Data::Dumper::Dumper(\%hash); } __END__ =head1 NAME dump_ndbm - Dump and undump a NDBM file =head1 DOWNLOAD _SRC_HERE_ =head1 SYNOPSIS # Dump a NDBM file dump_ndbm dbm_file >data.dump # Undump a dump into a NDBM file dump_ndbm -u data reads binary data files created by Perl's C module and dumps them in C format. This is useful if you want to peek what's inside a C data file. If you save the output of C in a file, you can even edit it: C can also convert C output back into a NDBM file if called with the C<-u> option. =head1 LEGALESE Copyright 2003 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =head1 AUTHOR Mike Schilli Em@perlmeister.comE