Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Make CSV list from values in AoH

by kevbot (Priest)
on Aug 18, 2018 at 06:44 UTC ( #1220559=note: print w/replies, xml ) Need Help??


in reply to Make CSV list from values in AoH

Hello tel2,

Here is a way to do it with help from the Text::CSV::Slurp module.

#!/usr/bin/env perl use strict; use warnings; use Text::CSV::Slurp; my @aoh = ( { name => 'Adam', age => 0 }, { name => 'Bob', age => 10 }, { name => 'Cat', age => 20 } ); open my $fh, '>', 'output.csv' or die $!; if( scalar @aoh > 0 ){ my $csv = Text::CSV::Slurp->create( input => \@aoh, always_quote => 1, quote => "'" ); print $fh $csv; } else { print $fh "''"; } $fh->close; exit;

Replies are listed 'Best First'.
Re^2: Make CSV list from values in AoH
by tel2 (Pilgrim) on Aug 20, 2018 at 01:27 UTC
    Thanks for that, kevbot.

    Not bad for a bot!

    tel2

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (4)
As of 2019-06-17 00:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (76 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!