# assume strict, and all other typical good code practices my $column = "UserName"; my $condition = "UserID"; my $qualifier = "101"; my ($rowcount, $UserID) = SQL_select($column, $condition, $qualifier); sub SQL_select { my $col = shift; my $cond = shift; my $qual = shift; my $sth = $dbh->("SELECT ? FROM DB.Table WHERE ? = ?"); $sth->execute($col, $cond, $qual); my $rowcount = $sth->rows; my $UserID = $sth->fetchrow_hashref; return ($rowcount, $UserID); }