AnyData/Format/Pipe.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/Storage/PassThru.pm ↑ Summary AnyData/Format/Tab.pm »
1 #########################################################
2 package AnyData::Format::Pipe;
3 #########################################################
4 # copyright (c) 2000, Jeff Zucker <jeff@vpservices.com>
5 # all rights reserved
6 #########################################################
7  
8 =head1 NAME
9  
10 AnyData::Format::Pipe - tiedhash & DBI/SQL access to Pipe delimited files
11  
12 =head1 SYNOPSIS
13  
14 use AnyData;
15 my $table = adHash( 'Pipe', $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','Pipe', $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 pipe separated list of column names
36  
37 If you are using this with DBD::AnyData, put ad_ in front of the flags, e.g.
38 ad_eol.
39  
40 Please refer to the documentation for AnyData.pm and DBD::AnyData.pm
41 for further details.
42  
43 =head1 AUTHOR & COPYRIGHT
44  
45 copyright 2000, Jeff Zucker <jeff@vpservices.com>
46 all rights reserved
47  
48 =cut
49  
50 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 1 ▶use AnyData::Format::CSV;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use vars qw( @ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
54 1 @AnyData::Format::Pipe::ISA = qw( AnyData::Format::CSV );
55  
56 1 $VERSION = '0.12';
57  
58 1 ▶sub new {
Subroutine new: called CC=3 SCAR=11.3
Pod undocumented
59 1 my $class = shift;
60 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
61 1 ▶ $flags->{field_sep} ||= q(\|);
Condition50%1/2
$flags->{"field_sep"} ||= "\\|"
l!l
01
MC/DC0%0/1
$flags->{"field_sep"} ||= "\\|"
$flags->{"field_sep"}
Truth table50%1/2
A
A= $flags->{"field_sep"}
Aresult
11
00
62 # $flags->{field_sep} ||= q(\s*\|\s*);
63 # my $self = AnyData::Format::CSV::->new({
64 1 my $self = new AnyData::Format::CSV({
65 %$flags
66 });
67 1 return bless $self, $class;
68 }
69 1 1;
70 __END__
« AnyData/Storage/PassThru.pm ↑ Summary AnyData/Format/Tab.pm »