in reply to Example using CGI::Application::Plugin::Output::XSV

If you just want to create a csv file from the input structure without CGI, you can use Text::CSV_XS :
#!/usr/bin/perl use warnings; use strict; use Text::CSV_XS qw{ csv }; my @header = qw( first_name last_name phone ); csv(in => [ \@header, map [ @$_{@header} ], { first_name => 'Jack', last_name => 'Tors', phone => '555-1212' }, { first_name => 'Frank', last_name => 'Rizzo', phone => '555-1515' }, ]);
map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Example using CGI::Application::Plugin::Output::XSV
by Tux (Canon) on May 09, 2020 at 19:20 UTC

    You don't need the map. AOH is supported:

    #!/usr/bin/perl use warnings; use strict; use Text::CSV_XS qw( csv ); my @header = qw( first_name last_name phone ); csv (in => [{ first_name => "Jane", last_name => "Rizzoli", phone => "555-1212" }, { first_name => "Maura", last_name => "Isles", phone => "555-1515" }, ], headers => \@header, );

    Or if you have the hash list already.

    my @header = qw( first_name last_name phone ); my @aoh = ( { first_name => "Jane", last_name => "Rizzoli", phone => "555-1212" }, { first_name => "Maura", last_name => "Isles", phone => "555-1515" }, ); csv (in => \@aoh, headers => \@header);

    Enjoy, Have FUN! H.Merijn
Re^2: Example using CGI::Application::Plugin::Output::XSV
by logangha (Acolyte) on May 08, 2020 at 18:34 UTC

    Thanks choroba
    I will keep it in mind