#! perl
use strict;
my( $key, @array ) = split "\t", <>;
while( <> ) {
chomp;
my( $newKey, $value ) = split "\t";
if( $newKey eq $key ) {
push @array, $value;
next;
}
else {
# Process @array for $key
#...
## Remember the newKey
$key = $nextKey;
## And the reset the array
@array = $value;
}
}
####
sort < unsortedFile | perl theScriptAbove
####
sort < unsortedFile > sortedFile
perl theScriptAbove sortedFile