Hello everyone, I'm writing to solicit comments on an enhancement to the CGI::Application::Plugin::Output::XSV module suggested by Mark Stosberg. This module is used to simplify generating CSV output from a CGI::App runmode.
Per Mark's request[1] (RT #21878): My wish for it is streaming support. Potentially supplying $values up front could be expensive, loading a huge file into memory. It would be nice to process and print out a row at a time, significantly reducing the overhead. Previously, the module required a precomputed list of values to generate the CSV output. Tonight, I added preliminary support for using an iterator to generate each row of the data set rather than requiring the user to supply a pregenerated list up front. You can check it out a preliminary version here: http://www.zacks.org/cgiapp-xsv/CGI-Application-Plugin-Output-XSV-0.9_01.tar.gz http://www.zacks.org/cgiapp-xsv/CGI-Application-Plugin-Output-XSV-0.9_01/ Let me know what you think of the interface. Basically, instead of requiring "values" (a reference to a list comprising the data set), you can pass the "iterator" parameter (a reference to a subroutine) which will be called until it returns a false value. Here is an example of how you might use the new feature: # in some runmode ... # $sth is a prepared/executed DBI statement handle sub get_entries { while ( my $list_ref = $sth->fetchrow_arrayref() ) { return $list_ref; } }; return $self->xsv_report_web({ include_headers => 0, iterator => \&get_entries, }); There are two other code samples using iterators at the end of the examples section of the pod: http://www.zacks.org/cgiapp/xsv/CGI-Application-Plugin-Output-XSV-0.9_01/pod.html#examples All comments and suggestions are welcome. Thanks, -E 1. http://rt.cpan.org/Public/Bug/Display.html?id=21878 --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[email protected]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
