Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: get keys from array of hashes

by PerlSufi (Friar)
on Aug 01, 2014 at 21:35 UTC ( [id://1095965]=note: print w/replies, xml ) Need Help??


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 :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1095965]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-20 00:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found