#!/usr/bin/perl -w # use strict; use DBI; $|++; # Create the variables that will be loaded from '.dbinfo' our ($db, $table, $user, $pass, $query); # Load them up do ".dbinfo" or die "Database info not found!\n"; my $dbh = DBI->connect("DBI:mysql:$db", $user, $pass); my $sth = $dbh->prepare("select $query from $table"); $sth->execute; while (my $hash_ref = $sth->fetchrow_hashref){ for my $key (keys %$hash_ref){ printf "%-10s: %s\n", $key, $hash_ref->{$key}; } }