Querylet::Output - generic output handler for Querlet::Query
version 0.402
This is an abstract base class, meant for subclassing.
package Querylet::Output::Tabbed; use base qw(Querylet::Output); sub default_type { 'tabbed' } sub handler { \&as_tabbed } sub as_tabbed { my ($query) = @_; my @output; push @output, join("\t", @{$query->columns}); push @output, join("\t", @{$_{@{$query->colummns}}}) for @{$query->results}; return join("\n", @output); } 1;
Then, in a querylet:
use Querylet::Output::Tabbed; output format: tabbed
Or, to override the registered type:
use Querylet::Output::Tabbed 'tsv'; output format: tsv
This class provides a simple way to write output handlers for Querylet, mostly by providing an import routine that will register the handler with the type-name requested by the using script.
The methods default_type and handler must exist, as described below.
default_type
handler
This code is effectively abandonware. Although releases will sometimes be made to update contact info or to fix packaging flaws, bug reports will mostly be ignored. Feature requests are even more likely to be ignored. (If someone takes up maintenance of this code, they will presumably remove this notice.)
Querylet::Output provides an import method that will register the handler when the module is imported. If an argument is given, it will be used as the type name to register. Otherwise, the result of default_type is used.
import
This method returns the name of the type for which the output handler will be registered if no override is given.
This method returns a reference to the handler, which will be used to register the handler.
Ricardo SIGNES <rjbs@semiotic.systems>
This software is copyright (c) 2004 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Querylet, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Querylet
CPAN shell
perl -MCPAN -e shell install Querylet
For more information on module installation, please visit the detailed CPAN module installation guide.