#!/usr/bin/perl -w

use strict;
use DBI;

my $thing = shift || 'muttley';

$thing .= " ".(join " ", @ARGV);

my $dbh = DBI->connect( 'dbi:mysql:diana',
                        '$username',
			'$password'
                      ) || die "DB connection not made - $DBI::errstr\n";

$thing = $dbh->quote("$thing");


foreach my $dir (qw(positive negative))
{ 	   
	print ucfirst($dir)."\n----------------------\n\n";
	my $sql = qq{select pvalue from t_${dir}karmacomments where pkey like $thing};
	my $sth = $dbh->prepare($sql); $sth->execute;
	my $val = 1;
	my $result =  $sth->fetchrow_array;
	goto SKIP unless defined $result;
	foreach (split ',*"', $result)
	{
		next if /^\s*$/;
		chomp;
		s/^\s*//;
		s/\s*$//;
		print "$val) ".$_."\n";;
		$val++;
	}
	SKIP : print "\n\n";
	
}

my $sql = qq{select pvalue from t_plusplus where pkey like $thing};
my $sth = $dbh->prepare($sql); $sth->execute;
printf "-----------------------\n\ttotal = %s\n-----------------------\n", $sth->fetchrow_array;
$sth = undef;

$dbh->disconnect;
exit 0;


syntax highlighted by Code2HTML, v. 0.9