in reply to Re^4: Appending data to large files
in thread Appending data to large files
Here's a self-contained runnable version of the code I posted in Re: Appending data to large files.
my $record_end = qq{\$\$\$\$\n}; while (<DATA>) { next if ( $_ ne $record_end ); print "--CSV stuff--\n"; } continue { print; } __DATA__ example 1 example 2 END $$$$ example 3 example 4 END $$$$
Here's the output:
example 1 example 2 END --CSV stuff-- $$$$ example 3 example 4 END --CSV stuff-- $$$$
Unless I've misunderstood your requirements, this is putting the CSV stuff right where you want it.
Integrating that with the CSV-handling code I posted in Re^3: Appending data to large files (and the rest of your program, of course) is up to you.
As for your question about headers, a quick look at the Text::CSV_XS documentation reveals a column_names method. That's what I'd try first. If that doesn't work out, then maybe a longer quick look would be required.
|
|---|