#!/usr/bin/perl -w

use strict;
use DBI;

my $thing = shift || 'muttley';

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

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



my $sql = qq{select * from t_plusplus};
my $sth = $dbh->prepare($sql); 
$sth->execute;

my %karma;
while (my ($name, $val) = $sth->fetchrow_array)
{
	$karma{$name} = $val;
}

$sth = undef;
$dbh->disconnect;

my $val = 1;
my @sorted = sort {$karma{$b} <=> $karma{$a}} keys %karma;
foreach (@sorted)
{
	printf "%d) %s = %s\n", $val++, $_, $karma{$_};
}

exit 0;


syntax highlighted by Code2HTML, v. 0.9