AnyData/Format/Tab.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 84.3% 27 / 32 CC 3 SCAR 6.4
CC
3
Cov
92%
new
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« AnyData/Format/Pipe.pm ↑ Summary AnyData/Format/Base.pm »
1 #########################################################
2 package AnyData::Format::Tab;
3 #########################################################
4 # copyright (c) 2000, Jeff Zucker <jeff@vpservices.com>
5 # all rights reserved
6 #########################################################
7  
8 =head1 NAME
9  
10 AnyData::Format::Tab - tiedhash & DBI/SQL access to Tab delimited files
11  
12 =head1 SYNOPSIS
13  
14 use AnyData;
15 my $table = adHash( 'Tab', $filename,'r',$flags );
16 while (my $row = each %$table) {
17 print $row->{name},"\n" if $row->{country} =~ /us|mx|ca/;
18 }
19 # ... other tied hash operations
20  
21 OR
22  
23 use DBI
24 my $dbh = DBI->connect('dbi:AnyData:');
25 $dbh->func('table1','Tab', $filename,$flags,'ad_catalog');
26 my $hits = $dbh->selectall_arrayref( qq{
27 SELECT name FROM table1 WHERE country = 'us'
28 });
29 # ... other DBI/SQL operations
30  
31 =head1 DESCRIPTION
32  
33 This is a plug-in format parser for the AnyData and DBD::AnyData modules. It will read column names from the first row of the file, or accept names passed by the user. In addition to column names, the user may set other options as follows:
34  
35 col_names : a tab separated list of column names
36 eol : the end of record mark, \n by default
37 quote_char : the character used to quote fields " by default
38 escape_char : the character used to escape the quote char, " by default
39  
40 If you are using this with DBD::AnyData, put ad_ in front of the flags, e.g.
41 ad_eol.
42  
43 Please refer to the documentation for AnyData.pm and DBD::AnyData.pm
44 for further details.
45  
46 =head1 AUTHOR & COPYRIGHT
47  
48 copyright 2000, Jeff Zucker <jeff@vpservices.com>
49 all rights reserved
50  
51 =cut
52  
53 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 1 ▶use AnyData::Format::CSV;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 1 ▶use vars qw( @ISA $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
57 1 @AnyData::Format::Tab::ISA = qw( AnyData::Format::CSV );
58  
59 1 $VERSION = '0.12';
60  
61 1 ▶sub new {
Subroutine new: called CC=3 SCAR=11.3
Pod undocumented
62 1 my $class = shift;
63 1 ▶ my $flags = shift || {};
Condition50%1/2
shift() || {}
l!l
10
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
64 1 ▶ $flags->{field_sep} ||= qq(\t);
Condition50%1/2
$flags->{"field_sep"} ||= "\t"
l!l
01
MC/DC0%0/1
$flags->{"field_sep"} ||= "\t"
$flags->{"field_sep"}
Truth table50%1/2
A
A= $flags->{"field_sep"}
Aresult
11
00
65 1 my $self = AnyData::Format::CSV::->new(
66 $flags
67 );
68 1 return bless $self, $class;
69 }
70 1 1;
« AnyData/Format/Pipe.pm ↑ Summary AnyData/Format/Base.pm »