/[webpac2]/trunk/lib/WebPAC/Input/Ovid.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 /trunk/lib/WebPAC/Input/Ovid.pm

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

revision 1124 by dpavlin, Sun Apr 19 23:35:31 2009 UTC revision 1130 by dpavlin, Tue Apr 21 21:06:29 2009 UTC
# Line 20  Version 0.01 Line 20  Version 0.01
20  =cut  =cut
21    
22  our $VERSION = '0.01';  our $VERSION = '0.01';
23    our $debug = 0;
24    
25  =head1 SYNOPSIS  =head1 SYNOPSIS
26    
# Line 79  sub new { Line 80  sub new {
80                  $line =~ s{[\r\n]+$}{};                  $line =~ s{[\r\n]+$}{};
81                  next if $line eq '';                  next if $line eq '';
82    
83                  warn "<< $line\n";                  warn "<< $line\n" if $debug;
84    
85                  if ( $line =~ m/^<(\d+)>$/ ) {                  if ( $line =~ m/^<(\d+)>$/ ) {
                         my $expect_rec = $#{ $self->{_rec} } + 2;  
                         warn "wrong Ovid record number: $1 != $expect_rec" unless $1 == $expect_rec;  
86                          push @{ $self->{_rec} }, $rec if $rec;                          push @{ $self->{_rec} }, $rec if $rec;
87                          warn "## rec = ",dump( $rec ),$/;                          warn "## rec = ",dump( $rec ),$/ if $debug;
88                          $rec = { '000' => $1 };                          my $expect_rec = $#{ $self->{_rec} } + 2;
89                            warn "wrong Ovid record number: $1 != $expect_rec" if $debug && $1 != $expect_rec;
90                            $rec = { '000' => [ $1 ] };
91                  } elsif ( $line =~ /^(\w.+)/ ) {                  } elsif ( $line =~ /^(\w.+)/ ) {
92                          $tag = $1;                          $tag = $1;
93                          warn "++ $tag\n";                          warn "++ $tag\n" if $debug;
94                  } elsif ( $line =~ /^\s\s(.+)/ ) {                  } elsif ( $line =~ /^\s\s(.+)/ ) {
95                          my $v = $1;                          my $v = $1;
96                          $v =~ s{[\s\.]+$}{};                          $v =~ s{[\s\.]+$}{};
97                          $rec->{$tag} = $v;                          $rec->{$tag} = [ $v ];
98                  } else {                  } else {
99                          warn "### skip: '$line'\n";                          warn "### skip: '$line'\n" if $debug;
100                  }                  }
101    
102          }          }
103    
104          # save last rec          # save last rec
105          push @{ $self->{_rec} }, $rec if $rec;          push @{ $self->{_rec} }, $rec if $rec;
         $self->{size} = $#{ $self->{_rec} } + 1;  
106    
107          $log->debug("loaded ", $self->size, " records");          $log->debug("loaded ", $self->size, " records");
108    
# Line 136  Return number of records in database Line 136  Return number of records in database
136    
137  sub size {  sub size {
138          my $self = shift;          my $self = shift;
139          return $self->{size};          return $#{ $self->{_rec} } + 1;
140  }  }
141    
142  =head1 AUTHOR  =head1 AUTHOR

Legend:
Removed from v.1124  
changed lines
  Added in v.1130

  ViewVC Help
Powered by ViewVC 1.1.26