#!/usr/bin/perl -w use strict; use warnings; my $line; while () { chomp; if (/^$/) { print "\n"; $line = ""; } elsif (/^[A-Z]{2}:\s/) { print "$line\n" if($line); $line = $_; } else { $line .= " $_"; } } print "$line\n" if($line); __DATA__ DN: Data Name Information Sciences TI: Title Distribution and abundance of bound volumes of the file in institute shelves from 1978 AU: Author Sahu, SR; Gawas, AKG AF: Affiliation Inst. of document scanning and documentation profiling at library, toward the prograssive society and establishment SO: Source Test document file. Vol. 5, no. 1, pp. 1-14. Jul 1990. DE: Descriptors Article Subject Terms: Abundance; Ecological distribution; Geographical distribution; Life cycle; Zooplankton; Article Taxonomic Terms: Euphausia; Article Geographic Terms: ISW, LA: Language English