ResultSet/Display/CSV.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 57 CC 4 SCAR 17.6
CC
4
Cov
0%
init
12.0
display_one
6.0
version
2.0
CRAP 5.8
1 package VUser::ResultSet::Display::CSV;
2 use warnings;
3 use strict;
4  
5 # Copyright 2006 Randy Smith <perlstalker@vuser.org>
6 # $Id: CSV.pm,v 1.1 2006-01-06 23:53:16 perlstalker Exp $
7  
8 use base qw(VUser::ResultSet::Display);
9  
10 use VUser::ExtLib qw(:config);
11  
12 my $c_sec = 'Display::CSV';
13  
14 our $VERSION = "0.3.1";
15 sub version { return $VERSION; }
16  
17 sub init
18 {
19 my $self = shift;
20 my $cfg = shift;
21  
22 my $sep = strip_ws($cfg->{$c_sec}{'separator'});
23 if (not defined $sep) {
24 $sep = ',';
25 } elsif ($sep eq '\t'
26 or $sep eq '[tab]'
27 or $sep eq 'tab'
28 ) {
29 $sep = "\t";
30 }
31  
32 $self->{sep} = $sep;
33 }
34  
35 sub display_one
36 {
37 my $self = shift;
38 my $rs = shift;
39  
40 print join $self->{sep}, map { $_->name; } $rs->get_metadata;
41 print "\n";
42  
43 foreach my $row ($rs->results()) {
44 print join $self->{sep}, map { (defined $_)? $_ : 'undef'; } @$row;
45 print "\n";
46 }
47 }
48  
49 1;
50  
51 __END__