if ($ARGV[0] eq "-a") { open (INFILE, "$ARGV[1]") or die "$ARGV[1] cannot be openned : $!"; my %hash; while ($source_file =~ /(\d)\s+(\d)\s+(\d)\s+(\w+)/) { push @{$hash{$4}}, $1, $2, $3; } print "@{$hash{$_}}[0..2] $_\n" for sort keys %hash; }