I have a CSV file in the following format:
Config,name,sub,produce,negative,positive,dying
RDF-12,jakl,xol,12,4,2,4
In my perl script, I have following variables:
$config = 'LSF-13'
$produce = 34;
$positive = 6;
$dying = 3;
I am missing variables for the columns 'name', 'sub', and 'negative' but still want to place(append) my variables in their respective columns.
$file = "/lsd/filepath/text.csv";
open $fh, '>>', $file or warn "can't open";
print $fh $config, $produce, $positive, $dying;
My code is not allowing me to specify the columns I want to match with my variable however.
Desired Output:
Config,name,sub,produce,negative,positive,dying
RDF-12,jakl,xol,12,4,2,4
LSF-13,,,34,,6,3
undeffor the fields that are missing?$config, undef, undef, $produce, undef, $positive, $dyingLSF-13get "appended" to theConfigfield ... likeRDF-12 LSF-13...?say $fh $config, ',', ',', $produce ...(etc). But, isn't there more to it? What if you have more lines to add, how do you designate variables (hash with column names?)