Thanks Rolf!
I believe I was able to make your idea work. I've posted a solution below, feel free to critique if you have the notion.
my $wait_for_odd_quotes = 0; my $line_accumulator = ''; while(<$CSVFILE>) { chomp(my $this_line = $_); my @matches = $this_line =~ /(\")/g; my $count = @matches; if($wait_for_odd_quotes == 0){ if($count % 2 == 1){ $line_accumulator = $this_line; #Reset Accumulator $wait_for_odd_quotes = 1; #Prime next loop to look for end + of quotes } else { print $OUTFILE $this_line . "\n"; #We are not looking for +and end quote and this line doesn't have an odd number of quotes so w +e'll write it to file } } else { if($count % 2 == 1){ $line_accumulator .= $this_line; #matched our open quotes, + taking this last bit $wait_for_odd_quotes = 0; #reset so next loop knows we're +not looking to close print $OUTFILE $line_accumulator . "\n"; } else { $line_accumulator .= ' ' . $this_line; } } } print $OUTFILE $line_accumulator . "\n"; #catch final line if it had e +mbedded newlines
In reply to Re^2: Embedded Newlines or Converting One-Liner to Loop
by mwb613
in thread Embedded Newlines or Converting One-Liner to Loop
by mwb613
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |