/[webpac2]/branches/Sack/lib/WebPAC/Input/ISI.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /branches/Sack/lib/WebPAC/Input/ISI.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 902 by dpavlin, Wed Oct 10 21:00:27 2007 UTC revision 1194 by dpavlin, Wed May 27 09:31:35 2009 UTC
# Line 6  use strict; Line 6  use strict;
6  use WebPAC::Input;  use WebPAC::Input;
7  use base qw/WebPAC::Common/;  use base qw/WebPAC::Common/;
8    
9    use Data::Dump qw/dump/;
10    
11  =head1 NAME  =head1 NAME
12    
13  WebPAC::Input::ISI - support for ISI Export Format  WebPAC::Input::ISI - support for ISI Export Format
14    
15  =head1 VERSION  =head1 VERSION
16    
17  Version 0.01  Version 0.02
18    
19  =cut  =cut
20    
21  our $VERSION = '0.01';  our $VERSION = '0.02';
   
22    
23  =head1 SYNOPSIS  =head1 SYNOPSIS
24    
# Line 56  path to ISI export file Line 57  path to ISI export file
57    
58  my $subfields = {  my $subfields = {
59          'CR' => sub {          'CR' => sub {
60                  my @v = split(/, /, shift);                  my $full_cr = shift;
61                  my $f;                  my @v = split(/, /, $full_cr);
62                    my $f = { full => $full_cr };
63                  foreach ( qw/author year reference volume page/ ) {                  foreach ( qw/author year reference volume page/ ) {
64                          if ( my $tmp = shift @v ) {                          if ( my $tmp = shift @v ) {
65                                  $f->{$_} = $tmp;                                  $f->{$_} = $tmp;
# Line 105  sub new { Line 107  sub new {
107          my $tag;          my $tag;
108          my $rec;          my $rec;
109    
110            $self->{size} = 0;
111    
112          while( $line = <$fh> ) {          while( $line = <$fh> ) {
113                  chomp($line);                  chomp($line);
114    
# Line 120  sub new { Line 124  sub new {
124                          foreach ( qw/AB DE ID TI/ ) {                          foreach ( qw/AB DE ID TI/ ) {
125                                  $rec->{$_} = join(' ', @{ $rec->{$_} }) if defined $rec->{$_};                                  $rec->{$_} = join(' ', @{ $rec->{$_} }) if defined $rec->{$_};
126                          }                          }
127                            $rec->{'000'} = [ ++$self->{size} ];
128                          push @{ $self->{_rec} }, $rec;                          push @{ $self->{_rec} }, $rec;
129                          $rec = {};                          $rec = {};
130                          $line = <$fh>;                          $line = <$fh>;
# Line 131  sub new { Line 136  sub new {
136                          $log->logdie("can't parse +$. $arg->{path} : $line");                          $log->logdie("can't parse +$. $arg->{path} : $line");
137                  }                  }
138    
139                  $v = $subfields->{$tag}->($v) if defined $subfields->{$tag};                  if ( defined $v ) {
140                            $v = $subfields->{$tag}->($v) if defined $subfields->{$tag};
141    
142                  push @{ $rec->{$tag} }, $v;                          $log->debug("$tag: ", sub { dump( $v ) });
143                            push @{ $rec->{$tag} }, $v;
144                    }
145    
146          }          }
147    
# Line 169  Return number of records in database Line 177  Return number of records in database
177    
178  sub size {  sub size {
179          my $self = shift;          my $self = shift;
180          return $#{$self->{_rec}} + 1;          return $self->{size};
181  }  }
182    
183  =head1 SEE ALSO  =head1 SEE ALSO

Legend:
Removed from v.902  
changed lines
  Added in v.1194

  ViewVC Help
Powered by ViewVC 1.1.26