# we assume 10 fields per record again while(read $fh, my $buffer, 128*2**10) { $buffer .= <$fh>; # we dump all records' fields in a big pile, in which # every 9th element contains the last field of one record, # plus a newline, plus the first field of the next record my @in_field_heap = split /\|/, $buffer; while(@in_field_heap) { # pull the two glued fields apart $in_field_heap[9] =~ /^([^\n]*)\n(.*)/; # pull out fields of current record incl the glued one, # and reinject the second half of the double field my @field = splice @in_field_heap, 0, 10, $2; # replace the glued double field by its first half @field[9] = $1; # ... } }