in reply to Class::CSV : How to write to CSV file?
Or, just write the output manually using the string() method:
#!/usr/bin/perl use strict; use warnings; use Class::CSV; my $report_csv = Class::CSV->new ( fields => [qw/VM_Name VM_Cluster vFiler_IP vFiler +_Cluster MisMatch/], ); $report_csv->add_line( { VM_Name => "VM1", VM_Cluster => "CLUSTER_1", vFiler_IP => "1.1.1.1", vFiler_Cluster => "CLUSTER_2", MisMatch => "What_is_that", } ); my $cvs_as_string = $report_csv->string(); my $outfile = 'final.csv'; open(my $fh, '>', $outfile) or die "Unable to open file '$outfile' for + writing: $!"; print $fh $cvs_as_string; close($fh) or die "Unable to close file '$outfile': $ +!";
HTH,
Athanasius <°(((>< contra mundum
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Class::CSV : How to write to CSV file?
by slayedbylucifer (Scribe) on Jul 02, 2012 at 07:28 UTC |