PerlSufi has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; use Text::CSV; my $csv = Text::CSV->new( { binary => 1, eol => "\n" } ); my $file = "records.csv"; open( my $csv_fh, '>', $file ) or die "Unable to open $file for writin +g: $!\n"; my $AoH_records = [ { foo => 'bar', key => 'value', }, ]; my $columns = []; for my $key ( keys @{$AoH_records}[0] ) { push @{$columns}, $key; last if scalar(@{$columns}) == 10; } $csv->column_names( $columns );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: get keys from array of hashes
by roboticus (Chancellor) on Aug 01, 2014 at 21:42 UTC | |
by PerlSufi (Friar) on Aug 01, 2014 at 21:47 UTC | |
|
Re: get keys from array of hashes
by AppleFritter (Vicar) on Aug 01, 2014 at 21:27 UTC | |
by PerlSufi (Friar) on Aug 01, 2014 at 21:35 UTC | |
by AppleFritter (Vicar) on Aug 01, 2014 at 21:43 UTC | |
by PerlSufi (Friar) on Aug 01, 2014 at 21:46 UTC | |
|
Re: get keys from array of hashes
by Anonymous Monk on Aug 02, 2014 at 12:33 UTC | |
by AppleFritter (Vicar) on Aug 02, 2014 at 16:00 UTC |