#!/usr/bin/perl open FILE1, "cust" or die; my %hash; my %location; while (my $line=) { chomp($line); (my $word1,my $word2, my $word3) = split /\s+/, $line; push (@{$hash{$word2}},$word1); push (@{$location{$word2}},$word3); } for $user (sort keys %hash) { print "$user: @{$hash{$user}} \n"; } for $loc (sort keys %location) { print "$loc: @{$location{$loc}} \n"; }