my $sep = ';'; # field separator my $expected_field_count = scalar split /$sep/, <>; # header line while(<>) { chomp; my @fields = split /$sep/, $_; while(@fields < $expected_field_count) { my $fieldline = <>; my @l = split /$sep/, $_; $fields[-1] .= '
'. shift @l; push(@fields,@l) if @l; } ... }