perl -pe "s/^(.*?)\t(.*?)\|(.*?)\t(.*?)(?=\n)/$1$2\|$3$4/g;" inputfile