in reply to Re: get keys from array of hashes
in thread get keys from array of hashes

Thanks AppleFritter,
Your method SHOULD work, but I am just now realizing that the  ->column_names method itself is not working for me- but using  ->print($csv_fh, $columns) does?
UPDATE: This is what I did for me to get it work, I am not sure why the column_names method isn't working for me though..
my $columns = [ keys $AoH_records->[0] ]; $csv->print( $csv_fh, $columns );

Replies are listed 'Best First'.
Re^3: get keys from array of hashes
by AppleFritter (Vicar) on Aug 01, 2014 at 21:43 UTC

    You're welcome! *tips hat*

    What do you mean by "not working for me"? As far as I can tell, ->column_names() is not for printing column names to a CSV file; quoting Text::CSV's documentation:

    column_names

    Set the keys that will be used in the getline_hr () calls. If no keys (column names) are passed, it'll return the current setting.

    So I'd say ->print() is the way to go, yes.

      Gotcha, Thanks a bunch :)