That is what join is for:
$newline = join "|", map { "$_=$trec{$_}" } keys %trec; [download]
In reply to Re^3: Process large text data in array by hdb in thread Process large text data in array by hankcoder