File Coverage

blib/lib/AnyData/Format/Pipe.pm
Criterion Covered Total %
statement 17 17 100.0
branch n/a
condition 2 4 50.0
subroutine 5 5 100.0
pod 0 1 0.0
total 24 27 88.8


line stmt bran cond sub pod time code
1             #########################################################
2             package AnyData::Format::Pipe;
3             #########################################################
4             # copyright (c) 2000, Jeff Zucker
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
46             all rights reserved
47              
48             =cut
49              
50 1     1   5 use strict;
  1         1  
  1         37  
51 1     1   5 use warnings;
  1         1  
  1         26  
52 1     1   4 use AnyData::Format::CSV;
  1         1  
  1         22  
53 1     1   4 use vars qw( @ISA $VERSION);
  1         1  
  1         126  
54             @AnyData::Format::Pipe::ISA = qw( AnyData::Format::CSV );
55              
56             $VERSION = '0.12';
57              
58             sub new {
59 1     1 0 2 my $class = shift;
60 1   50     3 my $flags = shift || {};
61 1   50     4 $flags->{field_sep} ||= q(\|);
62             # $flags->{field_sep} ||= q(\s*\|\s*);
63             # my $self = AnyData::Format::CSV::->new({
64 1         10 my $self = new AnyData::Format::CSV({
65             %$flags
66             });
67 1         4 return bless $self, $class;
68             }
69             1;
70             __END__