Subject: | Add ability to disable output of header row |
Hi,
This module is great, and really helpful. You saved my having to write it
myself.
I have a feature request (with patch). It would be great if I
could disable writing of the header row on calls to create(). I've
attached a patch that adds a "include_header" boolean parameter.
Thanks,
Darian
Subject: | include_header_Slurp.diff |
--- lib/Text/CSV/Slurp.pm.orig 2012-04-12 18:11:28.398122939 -0400
+++ lib/Text/CSV/Slurp.pm 2012-04-12 18:27:32.757976198 -0400
@@ -77,15 +77,25 @@
delete $arg{field_order};
+ my $include_header = exists $arg{include_header}
+ ? $arg{include_header}
+ : 1;
+
+ delete $arg{include_header};
+
%arg = ( binary => 1, %arg );
my $csv = Text::CSV->new( \%arg );
- unless ( $csv->combine( @names ) ) {
- die "Failed to create the header row because of this invalid input: " . $csv->error_input;
+ if ( $include_header ) {
+ unless ( $csv->combine( @names ) ) {
+ die "Failed to create the header row because of this invalid input: " . $csv->error_input;
+ }
}
- my @string = $csv->string;
+ my @string = $include_header
+ ? $csv->string
+ : '';
for my $row ( @$list ) {
my @data;