ASCII-Dateien als assoziative Arrays

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

FileDB.pm
package FileDB;

use Carp;
use IO::File;
use strict;

sub TIEHASH {
   my ($pack, $filename, $ifs) = @_;
   my $db = new IO::File $filename;
   croak("cannot open $filename: $!") unless defined $db;
   my $self = {
      db => {},
      modified => 0,
      filename => $filename,
      ifs => $ifs,
   };
   while (<$db>) {
      chomp;
      my ($key) = split /$ifs/;
      next unless $key;
      $self->{db}->{$key} = $_;
   }
   $db->close;
   return bless $self, $pack;
}

 [Vorheriges Kapitel]  [Vorherige Seite]  [Inhaltsverzeichnis]  [Nächste Seite]  [Nächstes Kapitel]
Copyright © 1996, 1998, 1999, 2000 Andreas Borchert, in HTML konvertiert am 07.02.2000