in reply to Re^2: How to read data file into an array of hashes
in thread How to read data file into an array of hashes

You don't need (or want) to sort the town names into a separate array; after the AoH is loaded, you just need to loop over the list of sorted array elements, where the sorting is based on the "town" value, like this:
for my $entry ( sort { $a->{town} cmp $b->{town} } @client ) { printf "%s\t%s\t%s\n", $entry->{town}, $entry->{surname}, $entry-> +{firstname}; }
(not tested)

(updated to add missing "->" in the printf statement, based on fseng's reply below)

Replies are listed 'Best First'.
Re^4: How to read data file into an array of hashes
by fseng (Novice) on Jun 25, 2009 at 06:00 UTC
    Thanks graff.I tested the code. It keeps giving error message: Global symbol "%entry" requires explicit package name. I try to declare it as my %entry, then it gives error message: use of unintialized value in printf. I dont get it.
Re^4: How to read data file into an array of hashes
by fseng (Novice) on Jun 26, 2009 at 00:14 UTC
    Hi it does work. I think I did some stupid thing but it works perfect now. Thanks a lot.