On many websites, I had code to retrieve a list of data items for use in an HTML::Template TMPL_LOOP. Usually this code would use the DBI routine fetchall_arrayref() to get a list of hash references, one for each data item.

A reference to a list of field names or array indices. This parameter specifies the order of fields in each row of output.

If fields is not supplied, a list will be generated using the first entry in the values list. Note, however, that in this case, if the values parameter is a list of hashes, the field order will be random because the field names are extracted from a hash. If the values parameter is a list of lists, the field order will be the same as the data provided.

If fields is not supplied and iterator is used instead of values, the field list will be empty.

A reference to a subroutine that is used to generate each row of data. It is passed a reference to the list of fields (fields) as a parameter and should return a reference to a list (which will be passed to add_to_xsv()).

It will be called repeatedly to generate each row of data until it returns a false value.

This may be preferred to values when the data set is large or expensive to generate up-front. Thanks to Mark Stosberg for suggesting this option.

A reference to a subroutine used to filter each row of data (other than the header row) before it is passed to add_to_xsv. When the values parameter is supplied, a default filter is provided that produces each row in the order specified by headers. For example, the default filter for a values list of hash references is shown below.

This flag controls whether or not output is printed immediately or collected and returned to the caller. Set to a true value to remove buffering on STDOUT and to emit output as it is generated. This can save memory in the case of a large document, for example.

The default is false to retain backwards-compatibility. In general, it is probably more efficient to set this to a true value, but note that it breaks with the standard CGI::Application convention of returning generated content from your runmodes rather than printing it yourself.

This may be useful when you want to do some manipulation of the data before sending it to the user's browser or elsewhere. It takes the same named parameters (via a reference to a hash) as xsv_report_web except for filename, which is not applicable to this function.