use strict; $/ = ""; # paragraph mode. print "File Name,Author,Date (MM/DD/Year),TIME (H:M:S),Version No.,". "Number,Feature Name,Paragraph Number,Requirement Number\n"; while(<>) { # $_ =~ Author : foo\nNumber : abc.... # These regexps may need changing if you allow # other characters in them. You may find something # more general such as what I use for Feature # best for all fields... my ($author) = m/^Author\s+:\s+([\w ]+)$/m; my ($number) = m/^Number\s+:\s+([\w ]+)$/m; my ($version) = m/Version Number\s+:\s+([\w ]+)$/m; my ($feature) = m/Feature\s+:\s+([^\s].*)$/m; my ($filename) = m/File Name\s+:\s+([\w._-]+)$/m; my ($mod_date) = m!Modification Date\s+:\s+(\d{2}/\d{2}/\d{4})!m; # Hope that Paragraph Number etc occurs at the end of the # record. my ($otherjunk) = m/Paragraph(.*)$/s; my @paragraphs = (split /\n/, $otherjunk); shift @paragraphs; # don't need headings; foreach my $line (@paragraphs) { my ($para, $requirement) = split(/\s+/, $line); print qq{"$filename","$author","$mod_date","","$version",}. qq{"$number","$para","$requirement"\n}; } }