#!c:/perl/bin/perl -w use strict; use DBI; my $DEBUG = 0; my $hfnetchk_dir = "c:/progra~1/shavli~1/hfnetchk"; my $db_dir = "${hfnetchk_dir}/hfnc_db"; my $table = "hfnetchk"; my $db_file = "${db_dir}/${table}.dbf"; if (not -d $db_dir) { die "Database directory $db_dir does not exist: $!\n"; } my $dbh = DBI->connect("dbi:XBase:${db_dir}"); my ($sth, $sql, $rv, $row_hr); if (not -f $db_file) { die "Database file $db_file does not exist: $!\n"; } $sql = "select * from ${table}"; dprint("sql=", $sql); $sth = $dbh->prepare($sql); $rv = $sth->execute; dprint("rv=", $rv); while ($row_hr = $sth->fetchrow_hashref) { print "Record:\n"; my $k; for $k (keys %{$row_hr}) { print "\t$k = ", $row_hr->{$k}, "\n"; } } $rv = $dbh->disconnect; dprint("rv=", $rv); print "\nPress Enter to exit program. "; my $garbage = <>; sub dprint { if (not $DEBUG) { return; } print join('', map { $_ || 'undef' } @_), "\n"; }