in reply to OO Perl: classes and database access

I'm not really sure what your user object looks like so this make or may not work:

Instead of trying to populate the user object with an array, why not try passing the database output directly to it with a hashref? I've used this method on several projects:

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);

Then your user info new method basically could just bless the input

package User; sub new { my($class,$user_info) = @_; return bless $user_info,$class; }

Hope that helps