DBD-XBase

 view release on metacpan or  search on metacpan

bin/dbfdump.PL  view on Meta::CPAN


use Config;
my $filename = $0;

$filename =~ s/\.PL$//;
open OUT,">$filename" or die "Can't create $filename: $!";
chmod(0755, $filename);
print "Extracting $filename (with #! and variable substitution)\n";

print OUT <<"EOHEADER";
$Config{'startperl'} -w

EOHEADER

print OUT <<'EOBODY';

use XBase;
use Getopt::Long;
use strict;
$^W = 1;

my $stdin = 0;

if (defined $ARGV[$#ARGV] and $ARGV[$#ARGV] eq '-') {
	$stdin = 1; pop @ARGV;
}

my %options;
Getopt::Long::GetOptions( \%options,
	'help', 'version', 'info', 'rs=s', 'fs=s', 'undef=s', 'fields=s',
	'nomemo', 'memofile=s', 'memosep=s', 'table',
	'SQL',
	) or exit;

if (defined $options{'version'}) {
	print "This is dbfdump version $XBase::VERSION.\n";
	exit;
}

if ($stdin) {
	push @ARGV, '-';
	$options{'nomemo'} = 1;
}

if (@ARGV == 0 or defined $options{'help'}) {
	die <<'EOF';
Usage: dbfdump [ options ] files
    where the options specify
	--rs		output record separator (default newline)
	--fs		output field separator (default colon)
	--fields	comma separated list of fields to print (default all)
	--undef		what to print for NULL values (default empty string)
	--memofile	specifies unstandard name of attached memo file
	--memosep	separator for dBase III dbt's (default \x1a\x1a)
	--table		output in nice table format (needs Data::ShowTable)
    all having as parameter a string; and also
	--nomemo	do not try to read the memo (dbt/fpt) file 
	--info		only print info about the file and fields
	--version	print version of the XBase library
EOF
}

my %addopts = ();
if (defined $options{'nomemo'} or defined $options{'info'}) {
	$addopts{'ignorememo'} = 1;
}



( run in 0.863 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )