while() { chomp; @cpy=(); @cpy = split(/\|/); $cpy{$cpy[0]} = [@cpy]; } print "$_->[0]\t$_->[1]\n" for sort {$a->[0] <=> $b->[0]} values %cpy;