http://www.perlmonks.org?node_id=1090501


in reply to CSV file to C file conversion using perl

Something like this might work (won't necessarily work, but should give you an idea)
use strict; use warnings; $/ = 'END'; # see perldoc -v '$/' open my $infile, '<', '/NAME/OF/FILE.csv' or die; open my $outfile, '>', '/NAME/OF/FILE.c' or die; while ($infile) { s/\A \s+ | \s+ \z//gx; # delete leading and trailing whitespace my %record = split /\n|,/; # this is brittle, tweak as necessary # now do something with the record, for example... print $outfile "${record{memid}, FLASH(${record{size}})" # etc }