Redundant variable names are no excuse not to bind. Nor does SELECT * self-document at all, you have to go look at the following code to see which columns are really being asked for. And this being Perl, which has hashes and excellent text munging, there's no reason you need to be redundant either.
I shall paraphrase some code from chromatic's DBI is ok article on Perl.com:
sub bind_hash {
my $table = shift;
my %results;
my $sql = do {
local $" = ", ";
"SELECT @_ FROM $table";
};
my $sth = $dbh->prepare($sql);
$sth->execute();
$sth->bind_columns(map { \$results{$_} } @_);
return (\%results, sub { $sth->fetch() });
}
# ... later:
my ($res, $fetch) = bind_hash users => qw(name email);
while ($fetch->()) {
print "$res->{name} >$res->{email}>\n";
}
It's not optimal yet, but as you see, a little inventiveness goes a long way.
Makeshifts last the longest.