in reply to Textfile to csv with a small twist

There are probably a bunch of regexes you can use to do this with the /s flag, but I would just do it programmatically:
#!/usr/bin/perl -w my $output = ''; while(<DATA>){ if(/\:$/){$output .= qq|\n$_|} else {chomp($_);$output .= $_ . q|, +|}; } print $output; 1; __DATA__ heading1: this is a tst heading2: this is another test The result is: heading1: this,is,a,tst, heading2: this,is,another,test, C:\Temp>

Celebrate Intellectual Diversity