in reply to Re^3: Joining multiple lines together while parsing
in thread Joining multiple lines together while parsing

Hi
That last one works great, but is there a way, to add " to every field at the start and end, so that the values are like "value" so I can use it for csv?
  • Comment on Re^4: Joining multiple lines together while parsing

Replies are listed 'Best First'.
Re^5: Joining multiple lines together while parsing
by haukex (Archbishop) on Mar 24, 2017 at 11:33 UTC
    so I can use it for csv?

    Use Text::CSV:

    use Text::CSV; my $csv = Text::CSV->new({binary=>1, always_quote=>1, blank_is_undef=>1, eol=>$/, auto_diag=>2}); $csv->print(select, ['foo', 'bar']); __END__ "foo","bar"

    Replace the call to select with a $filehandle (open) if you're writing to a file.

Re^5: Joining multiple lines together while parsing
by hippo (Archbishop) on Mar 24, 2017 at 11:31 UTC

    Just use a proper CSV module which will do this automatically for you. eg Text::CSV