#!/opt/perl
use strict;
use warnings;
use lib ( '/www/cgi-bin/MyOutputXSV' );
use MyOutputXSV;
my $app = MyOutputXSV->new();
$app->run();
####
package MyOutputXSV;
use strict;
use warnings;
use parent 'CGI::Application';
use CGI::Application::Plugin::Output::XSV qw(:all);
# headers generated will be [ "first", "last", "phone" ]
sub setup {
my $self = shift;
$self->run_modes(
'generate_report' => 'generate_report',
);
$self->start_mode('generate_report');
}
sub generate_report {
my $self = shift;
return $self->xsv_report_web({
values => [
{ first_name => 'Jack',
last_name => 'Tors',
phone => '555-1212' },
{ first_name => 'Frank',
last_name => 'Rizzo',
phone => '555-1515' },
],
fields => [ qw(first_name last_name phone) ],
headers_cb => sub {
my @h = @{ +shift };
s/_name$// foreach @h;
return \@h;
},
});
}
1;
####
first last phone
Jack Tors 555-1212
Frank Rizzo 555-1515