my $datahash = $self->_fetchall(table => 'Table1'); open (NROUT, ">", "./bin/PhyloStr/tmp/tmp.txt") || die "$!"; foreach (@$datahash){ print NROUT ">G$_->{column1}T$_->{column2}\n$_->{column3}\n"; } close NROUT; undef($nrdatahash); # # # am i actually doing anything here? ################## sub for _fetchall: sub _fetchall { my ($self,%arg) = @_; my $stm = "select * from $arg{table}"; my $stmt = $dbh->prepare($stm) || die $dbh->errstr; $stmt->execute || die $dbh->errstr; ; my $array = $stmt->fetchall_arrayref({}); $stmt->finish() || die $dbh->errstr; ; return $array; }