[ Samuel Fourie : Jun 1 16:21 ] > id 10,bbb 20,cc ,ddd 1,eee 2 > id 11,bbb 20,cc 1,ddd 1,eee 2 > id 12,bbb 20,cc ,ddd 1,eee 2 #!/usr/bin/perl -w use strict; use warnings; open FILE, "<help.txt" or die "$!\n"; my $flag = 0; map { chomp; print ( (($flag++ and $_) ? "," : "") . ($_ ? $_ : "\n") ); $flag = 0 unless $_; } <FILE>; close FILE; -- Jason Armstrong