@array=; $_=join('', @array); s/(word1)\n(word2)/$1 $2/g; @array=split(/\n/, $_);