in reply to array splitting and sorting
my (%last_names, %first_names); while (<>) { my ($last, $first) = split /,/; # Instead of undef, you could use '++' if you want to # count names e.g. # $last_names{$last}++; # or treat as an array and push the data '$_' to the hash, # e.g. # push @{$last_names{$last}}, $_; # Or even create a hash of hashes, etc. $last_names{$last} = undef; $first_names{$first} = undef; } print "$_\n" for sort keys %last_names; #etc.
|
|---|