DBD::AnyData or DBD::CSV will take care of creating textfiles if that's what you really need. You should consider DBD::SQLite or a full RDBMS if you don't need textfiles.
In terms of the command line, you can use dbish, the DBI Interactive Shell found in DBI::Shell or for simpler needs, you can just write a very tiny wrapper that prepares and executes SQL from the command line along these lines (careful, this works, if you create or drop tables with it, you'll be creating or droping files):
#!perl -w
use strict;
use DBI;
sub do_help{ print "
Squish, the SQL Undernourished Interactve Shell
q | quit Quit the program
h | help | ? view this Help text
Anything else you enter is passed as a SQL string to DBD::CSV.
The SQL will be prepared and executed.
squish.pl, copyright 2004 by Jeff Zucker all rights reserved
may be freely modified or distributed under the same terms as perl
";}
my $dbh=DBI->connect('DBI:CSV(RaiseError=1,PrintError=0):');
print "Welcome to squish, the SQL Undernourished Interactve Shell!\n";
while (1) {
print "squish> ";
my $input = <>;
chomp $input;
next unless $input;
for ($input) {
/^(q|quit)$/i &&do{do_exit()};
/^(h|\?|help)$/i &&do{do_help(); last};
my($sth,$rv);
eval {
$sth = $dbh->prepare( $input );
$rv = $sth->execute;
};
print $@ if $@;
/^SELECT/i &&do { $sth->dump_results; last};
print "$rv\n";
}
}
sub do_exit { $dbh->disconnect; exit; }
|