my @database; # loading the db while( my %row= get_a_row()) { push @database, \%row; } # put the row in the db # printing the results # first the keys my $row1= $database[0]; # I assume there is at least 1 row # and thet all rows have the same keys my @keys= keys %$row1; # %$row1 returns the hash referenced by $row1 print join( "\t", @keys), "\n"; # or however you want to print them # print the values, tab separated, 1 row/line foreach my $row (@database) { print join( "\t", values %$row), "\n"; } # same as with keys, just more concise }