my ($result_ref, $columnNames_ref, $numFields) = fetchRowArray($dbh, $sql); ... sub fetchRowArray($$){ my $dbh = shift; my $sql = shift; my $sth = $dbh->prepare($sql) or meldeFehler("Statement could not prepared"); $sth->execute() or meldeFehler("Statement could not executed"); my $columnNames; $columnNames = $sth->{NAME}; my $numfields; $numfields = $sth->{NUM_OF_FIELDS}; my (@matrix) = (); while (my @ary = $sth->fetchrow_array()) { push(@matrix, [@ary]); } $sth->finish(); return \@matrix, $columnNames, $numfields; }