Eine Textdatei als assoziatives Array III

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]

TextFileDB.pm
sub load {
   my ($self) = @_;
   my $in = new IO::File $self->{dbfile} or return undef;
   $self->{records} = {};
   while (<$in>) {
      chomp;
      my $record = $self->{converter}->line_to_record($_);
      my $keyval = $record->{$self->{keyfield}};
      $self->{records}->{$keyval} = $record;
   }
   $in->close;
   $self->{changes} = 0;
   return 1;
}

sub initialize {}

sub required {
   return {
      dbfile => ref(''),
      converter => 'TextRecordConverter',
      keyfield => ref(''),
   };
}

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 1996 - 2003 Andreas Borchert, in HTML konvertiert am 01.10.2003