Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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
Domain Nodelet?
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 drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2022-09-30 02:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (125 votes). Check out past polls.

    Notices?