in reply to Sorting an array of hashes

Personally, I would simplify this more by removing the dependence on the $i variable. It is fine to have $i in the code for outputting, but if you want to remove it later you can be sure not to introduce bugs:
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"; }