my $i = 0; foreach my $hash ( @AoH_sorted ) { # Swap these for start with 0 $i++; print "$i\t"; foreach my $key ( keys %{$hash} ) { print "$key\t"; } print "\n"; }