my $query = "SELECT * FROM users WHERE user=?"; my $sth = $dbh->prepare($query); $sth->execute($user) or die $sth->errstr(); # Here you have all the user's info in a hashref. The # keys are the same as the database column names. my $row = $sth->fetchrow_hashref(); # Then you could call the new method: my $user_info = User->new($row); #### package User; sub new { my($class,$user_info) = @_; return bless $user_info,$class; }