http://www.perlmonks.org?node_id=129362


in reply to Parsing multi-line records

use $/=undef to slurp all the file into a string. Replace all \n with commas except for the 12th?

$/=undef; # Slurps all data in file. $_=<DATA>; # Put it in $_, convenient for regex. my $lines=0; # Line count $. might suffice and then the pre increme +nt can be dropped. my $records=11; # Number of lines in a record. s/\n/(',',"\n")[++$line%$records==0]/eg;# replaces all \n with commas +except the recordth. print $_;

--

Brother Frankus.

¤