#!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; }