in reply to Logfile Summarize messages by time and export to CSV
The error indicated that you did not instantiate the $csv object. As huck already said, that could be something like:
use Text::CSV_XS; my $csv = Text::CSV_XS->new ({ binary => 1, eol => "\r\n", auto_diag = +> 1 });
(do not forget the eol attribute, because the default is undefined.)
But with that your code still won't run, as you didn't get the arguments to the print method correct. It expects a file handle and an anonymous list.
Assuming your @heading is a list of labels
$csv->print (OUT, \@heading);
Then inside the loop, you flatten the content. I am not sure if you want that. As the code shows now, it won't run anyway. If the result is indeed just one entry per row, as your loop is now (wich is strange for a header with more than one label)
$csv->print (OUT, [ $_ ]) for @arr;
but if your loop is to generate more fields per line
while (my $row = <IN>) { push @arr, [ unpack "x0 A12 ..." => $row ]; } # @arr now holds a list of array refs $csv->print (OUT, $_) for @arr;
|
|---|