1 package WebPAC::Input::TSV;
7 use base qw/WebPAC::Common/;
10 use Data::Dump qw/dump/;
14 WebPAC::Input::TSV - tab separated values
22 my $input = new WebPAC::Input::TSV(
23 path => '/path/to/records.tsv',
28 Default encoding of input file is C<utf-8>
39 my $log = $self->_get_logger();
41 open( my $fh, '<:raw', $arg->{path} ) || $log->logconfess("can't open $arg->{path}: $!");
45 while ( my $line = <$fh> ) {
49 $rec->{'000'} = [ ++$self->{size} ];
52 foreach my $v ( split(/\t/,$line) ) {
54 $rec->{ $col++ } = Encode::decode_utf8( $v );
57 push @{ $self->{_rec} }, $rec;
61 $log->debug("loaded ", $self->size, " records");
63 $self ? return $self : return undef;
68 Return record with ID C<$mfn> from database
70 my $rec = $input->fetch_rec( $mfn, $filter_coderef );
75 my ( $self, $mfn, $filter_coderef ) = @_;
77 return $self->{_rec}->[$mfn-1];
83 Return number of records in database
85 my $size = $input->size;
96 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
98 =head1 COPYRIGHT & LICENSE
100 Copyright 2010 Dobrica Pavlinusic, All Rights Reserved.
102 This program is free software; you can redistribute it and/or modify it
103 under the same terms as Perl itself.
107 1; # End of WebPAC::Input::TSV