in reply to how to get array's key name?

Generally, a good rule of thumb is It is possible to combine the two with an array of hashes (AoH). And you can use perl's each to get at the key/value pairs in the hashes.
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; my @db = ( {one => q{red}}, {two => q{green}}, {three => q{blue}}, ); #print Dumper \@db; for my $rec (@db){ my ($key, $value); while (($key, $value) = each %{$rec}){ print qq{$key -> $value\n}; } }
produces:
one -> red two -> green three -> blue